How to print 32 bit value complete?

I want to know that how to print the complete integer value with zero also in C only.

And i am in kernel space ,want to print some values in kernel module.

Like if a is a 32 bit integer then

int a = 14

then output will be like this

value of a = 0x0000000e

in hexa-decimal.

Thanks in advance.


Solution 1:

Put a 0 in the format:

printf("value of a = 0x%08x", a);

From the printf(3) man page:

'0' (zero)

Zero padding. For all conversions except n, the converted value is padded on the left with zeros rather than blanks. If a precision is given with a numeric conversion (d, i, o, u, i, x, and X), the 0 flag is ignored.

Nothing like the documentation to answer questions for you - at least if the documentation is any good.

Solution 2:

#include <stdio.h>

int main(int argc, char *argv[])
{
  int a = 14;

  printf("value of a = 0x%08x\n", a);

  return 0;
}