Thursday, November 1, 2012

%#x (or %#llx), in C language format string - Stack Overflow and wpollock

I was looking up %#llx (which I found nowhere, even using SymbolHound).  But this is close enough (for x, # causes value to be prepended by 0x).  It's a new one on me  :-)


KdPrint((
         "Unknown IoControlCode %#x\n",
                io_stack->Parameters.DeviceIoControl.IoControlCode
        ));
It's weird. What does sharp mean?
share|improve this question

feedback

3 Answers


The printf documentation says:
The character % is followed by zero or more of the following flags:
# The value should be converted to an ‘‘alternate form’’. For o conversions, the first character of the output string is made zero (by prefixing a 0 if it was not zero already). For x and X conversions, a non-zero result has the string ‘0x’ (or ‘0X’ for X conversions) prepended to it. For a, A, e, E, f, F, g, and G conversions, the result will always contain a decimal point, even if no digits follow it (normally, a decimal point appears in the results of those conversions only if a digit follows). For g and G conversions, trailing zeros are not removed from the result as they would otherwise be. For other conversions, the result is undefined.conversions, the result is undefined.
MSDN docs on the flags are here
so %#x the value is simply prefixed with 0x. Where %x would yield 34ab %#x would yield 0x34ab
share|improve this answer
Was this post useful to you?     

Do you know about %#x, in C language format string - Stack Overflow

And more specifically related to %#llx (new as of C99):

ll  (This is the letters ell-ell and not the digits one-one.)  The same as hh, except ll specifies the argument is a long long or unsigned long long.  (New as of C99.)
printf( "%#llX", 300 );0X12C


http://wpollock.com/CPlus/PrintfRef.htm

'via Blog this'

No comments:

Post a Comment