whatz wrong?
-
char *t1="Tommy"; char *t2="Lee"; strcat(t1,t2); whatz wrong with the above code? i'm using VC6.0.. the application gets terminated.. if i use char[] its working.... then y not char*? whatz the difference??
MOTLEY !!!! Sorry. First of all, you're asking in the C++/CLI board, which is for managed C++. Yeah, the new name makes it less clear. Secondly, you should prefer to use the std::string class, or even CString, rather than manipulating char *. Finally, the first argument passed into strcat should contain enough space after the null terminator to make room to copy in the second string. This is the sort of crap that makes C string handling really sucky, compared to using std::string. Christian Graus - Microsoft MVP - C++
-
char *t1="Tommy"; char *t2="Lee"; strcat(t1,t2); whatz wrong with the above code? i'm using VC6.0.. the application gets terminated.. if i use char[] its working.... then y not char*? whatz the difference??