Hi Anil,
#a is a preprocessor operator to convert the argument specified as string or
enclosing in double quotes. so, after macro expansion, the printf statement
would become
printf("%d\n",*"432"); =>
printf("%d\n","432"[0]);=>
printf("%d\n",*"4");
which prints the ASCII equivalent 52.
Similarly, using printf("%d\n", "432"[1]),printf("%d\n", "432"[2])
would yield 52 and 51 respectively. Let me know.
Thanks,
Balaji
On Wed, Sep 21, 2011 at 4:34 PM, Anil Arya <[email protected]> wrote:
>
>
>
> #include<stdio.h>
>
> #define power(a) #a
>
> int main(){printf("%d\n",*power(432));return 0;}
>
> why it is giving 52 as output?
>
>
>
>
>
> --
> *Anil Arya,
> Computer Science *
> *Motilal Nehru National Institute of Technology,Allahabad .
> *
>
>
> --
> 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.