On Sat, Dec 26, 2009 at 4:10 AM, Sunny Sharma <[email protected]> wrote:
> oh no! then it is creating a problem...never mind. well there is another one
> if int x = 1, y = 1;
> printf("%d",printf("%d%d",x,y));
>
> the output is coming 1 12 can you explain me how?
Yes it is correct!
printf operated in this way if it is used within another printf.
Lets take the innermost printf
printf("%d",x,y) -> is printed as 11 (clear)
the outer printf now works a bit tricky.
printf("%d", <previousprintfoutput>)
Now this printf prints the length of the characters printed by the
inner printf i.e two.
The net output is now 112 which is what you get.
If you modify the code to be something like printf("%d",printf("%d\t%d", x, y))
You will get 113 as output as \t is another character.
Hope it helps.
Aanjhan
_______________________________________________
Users mailing list
[email protected]
http://lists.dgplug.org/listinfo.cgi/users-dgplug.org