printf zero-pads strings?
Henry Spencer
henry at utzoo.uucp
Tue Oct 24 02:24:53 AEST 1989
In article <7279 at sdcsvax.UCSD.Edu> williams at beowulf.UCSD.EDU (Paul Williamson) writes:
>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.
The Oct 88 draft (essentially final except for wording changes) says that
the `0' flag in formatting specifications applies only to the numeric
conversions. Nothing is said about what happens otherwise, i.e. it is
undefined.
--
A bit of tolerance is worth a | Henry Spencer at U of Toronto Zoology
megabyte of flaming. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.std.c
mailing list