Program aborts when using strcpy on a char pointer? (Works fine on char array)

I'm perplexed as to why the following doesn't work:

char * f = "abcdef";
strcpy(f, "abcdef");
printf("%s",f);

char s[] = "ddd";
strcpy(&s[0], "eee");
printf("%s", s);

In both examples strcpy received a char * yet on the first example it dies a horrible death.

9
задан John Smith 13 March 2012 в 03:16
поделиться