> Can someone please explain why this program works in sunstudio C
> compiler but seg faults in gcc:
>
> #include <stdio.h>
> #include <string.h>
>
> int
> main()
> {
> char *ptr = "adam";
>
> strcpy(ptr, "eve");
> printf("%s\n", ptr);
> }
You can't write into string constants as per the ANSI C standard, but the
Sun compiler will let you do it unless you specify -xstrconst.
--
meem
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code