printf zero-pads strings?
Paul Williamson
williams at beowulf.ucsd.edu
Sun Oct 22 09:52:30 AEST 1989
Has the definition of printf changed since early drafts of the ANSI spec?
In particular, I am interested in the interpretation of
printf("%05s", "x");
According to my old draft spec, and several compilers, this should print
"0000x". That is, it should pad the string on the left with zeroes. But
K&R2 and several other compilers give " x", claiming that zero-padding
applies only to numeric values.
I know from my experiments with various compilers that it isn't safe to
use this construct in the real world. But I can't help but wonder which
compilers are right according to the current pANS. Language lawyers?
Paul Williamson williams%cs at ucsd.edu
More information about the Comp.std.c
mailing list