It means to output 4-bit shaping.
%04d means that when the number is less than 4 digits, it will be preceded by 0, making its total width 4 digits.
Remember, you can check the format of msdn's printf in detail.