Output minimum width
A decimal integer to represent the minimum number of digits of the output. If the actual number is more than the defined width, the actual digit is output, or a space or 0 if the actual number is less than the defined width (when the minimum width value begins with 0).
X indicates that output 02 in 16 is
less than two digits, the front is 0 output, and if more than two digits, the actual output is an
example:
printf ("%02x", 0x345); Print out: 345
printf ("%02x", 0x6);//Print out: A
and if directly written as%2X, the data is less than two bits, the actual output, that is, no additional 0 output, if more than two bits, the actual output.
printf ("%2x", 0x345); Print out: 345
printf ("%2x", 0x6);//Print out: 6
Example:
#include <stdio.h>
int main ()
{
int i =-20;
for (i = -20; i < i++)
{
printf ("%2x\n", I);
printf ("%02x\n", I);
}
return 0;
}
Output results:
Ffffffec
Ffffffec
Ffffffed
Ffffffed
Ffffffee
Ffffffee
Ffffffef
Ffffffef
Fffffff0
Fffffff0
Fffffff1
Fffffff1
Fffffff2
Fffffff2
Fffffff3
Fffffff3
Fffffff4
Fffffff4
Fffffff5
Fffffff5
Fffffff6
Fffffff6
Fffffff7
Fffffff7
Fffffff8
Fffffff8
Fffffff9
Fffffff9
Fffffffa
Fffffffa
Fffffffb
Fffffffb
Fffffffc
Fffffffc
Fffffffd
Fffffffd
Fffffffe
Fffffffe
Ffffffff
Ffffffff
0
00
1
01
2
02
3
03
4
04
5
05
6
06
7
07
8
08
9
09
A
0a
B
0b
C
0c
D
0d
E
0e
F
0f
10
10
11
11
12
12
13
13
14
14