%2d requires two bits of output data. If it is more than two digits, it will be output as it is, for example, 2. 123. If 2 is satisfied, it is filled with spaces (output 2 bits). If it sees 123, it outputs it as it is.
%2.0d I said I haven't met it. This should be a mistake. I tested it with compiler software, but I didn't test its usage.
Only these two formats are available.
%m.ns: output the string, where m specifies the output width and n indicates that the first n characters of the string are output to the screen. If m >;; N needs to be filled with spaces. For example, %5.3s means that the output width is 5, but actually only 3 characters are output, and 2 spaces are required.
% m.nf: m means to find the whole floating-point number output width, and n means the decimal number output width. For example, %5.2f outputs a 58.6238,
Then the actual output is 58.62. Note that m is the width when all data is input.
%02d: By default, if the data width is less than 2 digits, it is filled with spaces. But because there is a 0 in front of 2d, it means that if the data width is less than 0, it will be filled with 0. For example, if %03d outputs 12, the actual output to the screen is 0 12.
Handmade, please support.