why does this code crashes even though everything is perfectly fine?

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 5:15 UTC
Read the original article Hit count: 258

Filed under:
|

why does this code crashes when executed even though everything is fine? 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;
}

it should work fine but it isn't. 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