Question

KdPrint((
         "Unknown IoControlCode %#x\n",
                io_stack->Parameters.DeviceIoControl.IoControlCode
        ));

It's weird. What does sharp mean?

Was it helpful?

Solution

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.

MSDN docs on the flags are here.

so for %#x the value is simply prefixed with 0x. Where %x would yield 34ab, %#x would yield 0x34ab.

OTHER TIPS

# indcates an alternative format. For x this means that 0x is prepended to the output.

printf when used with specifier x, # causes the output to be prefixed with 0x provided the value being printed is other than 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top