Re: How does printf able to receive a pointer when passing it a string constant?

2009-05-13 Thread Jim Gibson
On 5/13/09 Wed May 13, 2009 4:48 AM, "Michael Alipio" scribbled: > I have a c code that looks like this: > > #include > > main (){ > char girl[] = "anna"; > char boy[] = "jude"; > stringcopy(boy, girl); /* copy boy to girl */ > printf("%s", girl); > > } > > void stringcopy(char *b, char *g)

Re: How does printf able to receive a pointer when passing it a string constant?

2009-05-13 Thread Chas. Owens
On Wed, May 13, 2009 at 07:48, Michael Alipio wrote: > > > I have a c code that looks like this: And C isn't Perl, perhaps you should ask these sort of questions on a C list or newsgroup[1]? Or maybe Stack Overflow[2]? snip > However if I replace the stringcopy call arguments with "jude", "anna

How does printf able to receive a pointer when passing it a string constant?

2009-05-13 Thread Michael Alipio
I have a c code that looks like this: #include 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