C language learning:% d, 2d, 02d, the difference .2d

%d: As a normal output.
Here Insert Picture Description
%2d: 2 in width is output, the output right-aligned manner. If two is not enough, left the meeting spaces.
Here Insert Picture Description
%02d: 2 of the same width, alignment to the right. The median is not enough left 0s.
Here Insert Picture Description
%.2d: From the implementation point of view, with the same% 02d.
Here Insert Picture Description

Published 100 original articles · won praise 45 · views 640 000 +

Guess you like

Origin blog.csdn.net/wangzhongshun/article/details/101431554