[LCP]snippets

Vincent Penquerc'h vincent at qubesoft.com
Tue Jul 17 19:16:03 UTC 2001


> the following are some snippets whose results surprise me.

And here are some comments:

> HTML email

Is is because your mailer is badly conigured.
And since Outlook (which I have to use here) is stupid beyond belief, it
does not even add my "> " markers in front of answers when the mail I
reply to is HTML, and it annoys me a LOT. So I won't do it by hand, hope
you can see where my comments are :)

main()
{
 int i=10;
 printf("%n",&i);
 printf("...%d",i);
}
...0 


Because %n counts the characters output at the time it is evaluated, so
there are 0 in your example. Normal behavior.


void main()
{
 printf("%p ",main);
}
0291


I'm a bit surprised that the pointer is so small, but why not ?
Is it what you meant ?


void main()
{
 printf("%x",-1);
}
ffff
(i understand that negative nos are stored in 2's complement form.
 but when retrieving also it should do 2's complement and output)


%x interprets a memory location as unsigned int. It had utterly no idea
of what you just pushed on the stack (which happens to be int, but it has
no (real) way of knowing.


--
Lyrian 



More information about the linuxCprogramming mailing list