thanx dave....
but this finally seemed to work....i guess it was the (char *) before the malloc that was needed
c3 = (char *)malloc(strlen(c1) + strlen(c2) +1);
strcpy(c3,c1);
strcat(c3,c2);
Type: Posts; User: sameerc
thanx dave....
but this finally seemed to work....i guess it was the (char *) before the malloc that was needed
c3 = (char *)malloc(strlen(c1) + strlen(c2) +1);
strcpy(c3,c1);
strcat(c3,c2);
hmm...then i guess i thought up the wrong reason....
i did allocate a lot of space....
let me paste some of my actual code... (you will see there's hardly any difference between the example...
tried but did not work...
i think it's cos c2 does not have an explicit '\0' character.....
so it crashes when it encounters the strcat() function...
-sameer
haven't used C/C++ in a while....so this might be really simple for most of you....
can someone please tell me how to concatenate two char * strings?
(one of them is const char* and the other one...
thanx a lot for your reply....
however, i ran the code that you listed in a MS vc++ environment, and it gives me an error:
error C2440: 'initializing' : cannot convert from 'void *' to 'char *'...
that doesn't work here cos I guess the getenv function returns a pointer to the whole PATH but the PATH does not have a defined '\0' character at the end....
haven't used C in a while....so this might be really simple for most of you....
can someone please tell me how to concatenate two char * strings?
eg.
char * c1 = "SYSTEM PATH = "
char *c2 =...