In pure ANSI C (C89), I have the following.
unsigned y=<smallnumber>,x=y+3;
printf("%<whatgoeshere>\n",x-y);
What do I put after the %
to be absolutely sure it will print 3
? I can see arguments for both %u
(result is unsigned if both operands are) and %d
(integral expressions are converted to int
when passing arguments to printf
) here.
Of course both work on any reasonable compiler, which is exactly why I ask here. :-) I have a feeling only one is really correct accordung to standard (but even that could be wrong).