These examples should show the difference:
"%0.2lf", 0.123 β 0.12 (zero filled minimum width of 0, 2 decimal places).
"%6.2lf", 0.123 β __0.12 (space at least 6, 2 decimal places wide).
"%06.2lf", 0.123 β "%06.2lf", 0.123 (zero minimum width of 6, 2 decimal places).
"%0.6lf", 0.123 β 0.123000 (minimum width is 0, 6 decimal places).
The first zero indicates zero padding, followed by the minimum width, which has a default value of 0. Thus, it is actually ignored by itself (since you cannot skip width 0).
By the way, the correct form is
%f , not
%lf for
printf .
source share