why does this code crash?

Posted by ashish yadav on Stack Overflow See other posts from Stack Overflow or by ashish yadav
Published on 2010-03-13T05:05:11Z Indexed on 2010/03/13 8:05 UTC
Read the original article Hit count: 274

Filed under:
|

why does this code crash? is using strcat illegal on character pointers?

#include <stdio.h>
#include <string.h>

int main()
{
   char *s1 = "Hello, ";
   char *s2 = "world!";
   char *s3 = strcat(s1, s2);
   printf("%s",s3);
   return 0;
}

please give a proper way with referring to both array and pointers.

© Stack Overflow or respective owner

Related posts about c

    Related posts about crash