in case of constant strings..they all return the same pointer..where they are defined.. but in case of non constant strings..like a[]="sumthing" and b[]="sumthing"...they will have separate memory allocations..
On Tue, Sep 6, 2011 at 9:12 PM, aditi garg <[email protected]>wrote: > It is basically comparing the addresses of the two and since p contains > the memory address of "persons" it gives the output as technical persons... > infact ull be surprised to see dis > > #include<stdio.h> > main(){char p[]="persons";char q[]="persons";if(p==q) > printf > <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("technical > %s",p);elseprintf > <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("true > %s",p);return 0;} > > output : true persons > > > #include<stdio.h> > main(){char *p="persons";char *q="persons";if(p==q) > printf > <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("technical > %s",p);elseprintf > <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("true > %s",p);return 0; > > } > bt Here output will be 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. >> > > > > -- > Aditi Garg > Undergraduate Student > Electronics & Communication Divison > NETAJI SUBHAS INSTITUTE OF TECHNOLOGY > Sector 3, Dwarka > New Delhi > > > -- > 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. > -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- 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.
