Re: [algogeeks] op

2010-06-16 Thread Anurag Sharma
Every time the function f() is called, it allocates an entirely new set of memory location, copies "goodbye" in it and returns its base address. So even if you assign 'A' to its first location, the first character of the array allocated by f() will still be 'g' if you call it the next time Thats wh

Re: [algogeeks] op

2010-06-16 Thread Anand
In all it calls *f() funtion twice once while executing *f()='A' and other when executing the printf statement. *f() is returing character pointer so if you print with %c, it prints g and if you print with %s and do not dereference the function you will be able to print goodbye. For reference: ht

Re: [algogeeks] op

2010-06-16 Thread harit agarwal
it is returning the address of last operation done in the accumulator. as the last operation is copying to s to it is returning s you will understand try running this,,... #include char *f() {char *s=malloc(8); strcpy(s,"goodbye"); } main() { *f()='A';

Re: [algogeeks] op

2010-06-15 Thread sharad kumar
ya i forgot that...considering that plz explain o/p i.e #include char *f() {char *s=malloc(8); strcpy(s,"goodbye"); return s; } main() { *f()='A'; printf("%c",*f()); } -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] op

2010-06-15 Thread Anurag Sharma
did you forget to return any value from function f() ? Anurag Sharma On Mon, Jun 14, 2010 at 7:19 PM, sharad wrote: > #include > char *f() > {char *s=malloc(8); >strcpy(s,"goodbye"); > } > > main() > { > *f()='A'; > printf("%c",*f()); } > > > find

[algogeeks] op

2010-06-15 Thread sharad
#include char *f() {char *s=malloc(8); strcpy(s,"goodbye"); } main() { *f()='A'; printf("%c",*f()); } find o/p n explain it -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to th