I have a c code that looks like this:
#include<stdio.h> main (){ char girl[] = "anna"; char boy[] = "jude"; stringcopy(boy, girl); /* copy boy to girl */ printf("%s", girl); } void stringcopy(char *b, char *g){ while ((*g++ = *b++) != '\0') ; } It prints fine... However if I replace the stringcopy call arguments with "jude", "anna" it compiles fine but i get segmentation fault when running. How come printf can accept variable names as well as constant strings such as: printf ("%s", girl); and printf ("Hello World\n"); My stringcopy function only accepts pointers. Shouldn't I be passing pointer to the first element of "anna" when passing the string constant "anna"?? ) How does printf print a string constant then? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/