depends on compiler i think......but most probably it compares the addresses.....
On Wed, Jan 4, 2012 at 12:20 PM, saurabh singh <[email protected]> wrote: > @all.....Your explanations work because probably all of you are using a > compiler that's behaving in the same way.Don't conclude from what you > see...The compiler is free to store the constant strings the way it > wants......... > Saurabh Singh > B.Tech (Computer Science) > MNNIT > blog:geekinessthecoolway.blogspot.com > > > > On Wed, Jan 4, 2012 at 12:13 PM, Rahul <[email protected]> wrote: > >> it's near to a common mis conception that string liberals are in data >> sections of THE PROGRAM >> >> >> PLEASE READ THE FILE >> a.out.h >> >> and find the difference between initialized data and non initialized data >> >> On 9/6/11, Sandy <[email protected]> wrote: >> > String constants (literals) are saved into the .data section of the >> program, >> > Here is the sample program to show that. if() is essentially >> comparing the >> > addresses of two pointers which is same. >> > >> > int main() >> > { >> > char *p="persons"; >> > char *q="persons"; >> > char *r="persons"; >> > char *s="persons"; >> > printf("%x %x %x %x\n",p,q,r,s); >> > if(p=="persons") >> > printf("technical %s",p); >> > else >> > printf("true %s",p); >> > return 0; >> > } >> > ------------- >> > Output: >> > 403021 403021 403021 403021 >> > technical persons >> > >> > On Tue, Sep 6, 2011 at 9:04 PM, sivaviknesh s <[email protected] >> >wrote: >> > >> >> >> >> main() >> >> { >> >> char *p="persons"; >> >> clrscr(); >> >> if(p=="persons") >> >> printf("technical %s",p); >> >> else >> >> printf("true %s",p); >> >> return 0; >> >> } >> >> >> >> ..op : technical persons ..plz explain .. how come it works like an >> strcmp >> >> operation??? >> >> -- >> >> Regards, >> >> $iva >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> Groups >> >> "Algorithm Geeks" group. >> >> To post to this group, send email to [email protected]. >> >> To unsubscribe from this group, send email to >> >> [email protected]. >> >> For more options, visit this group at >> >> http://groups.google.com/group/algogeeks?hl=en. >> >> >> > >> > >> > >> > -- >> > >> > *Sandeep Kumar,* >> > ( Mobile +91-9866507368 >> > >> > *“I believe in smart work, Believe Me”* >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "Algorithm Geeks" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group at >> > http://groups.google.com/group/algogeeks?hl=en. >> > >> > >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
