c - strcat function how to use -
i pretty new in c language. trying use strcat, following example works:
char s1[20] = "happy "; char s2[15] = "world"; char s3[40] = ""; strcat(s3,s1);
although, wanted practise bit pointers have seen earlier, so:
char *s1 = "happy"; char *s2 = "world"; strcat(*s2,*s1);
produces argument of type "char" incompatible parameter of type "const char *. again, might easy, clarifying possible
in second example,
strcat(*s2,*s1);
has type mismatch problem, *s2
, *s1
of type char
. if use:
strcat(s2,s1);
it still wrong, because s2
points string literal, can't modified.
Comments
Post a Comment