Re: printf doesn't do right justify

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Quoted text here. Click to load it

The number before the . is the minimum total field width, not the number
of places before the decimal (yes, I think this is confusing too, but
it's more consistent with %3.5s). So you want

    printf("%4.1f\n", 12.3);
    printf("%4.1f\n", 4.5);
    printf("%04.1f\n", 6.7);


Site Timeline