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: http://codepad.org/Xo1J7bVN
Thanks,
Anand

On Tue, Jun 15, 2010 at 8:26 PM, sharad kumar <[email protected]>wrote:

> ya i forgot that...considering that plz explain o/p
> i.e
>  #include<malloc.h>
>      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
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[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.

Reply via email to