Article View: comp.std.c
Article #826Re: printf zero-pads strings?
From: Henry Spencer
Date: Mon, 23 Oct 1989 16:24
Date: Mon, 23 Oct 1989 16:24
16 lines
1185 bytes
1185 bytes
In article <7279@sdcsvax.UCSD.Edu> williams@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@zoo.toronto.edu
Technical Details
Message-ID:
<1989Oct23.162453.29413@utzoo.uucp>Path:
arc1-ca.pugleaf.net!utzoo!henryReferences:
<7279@sdcsvax.UCSD.Edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: printf zero-pads strings? Message-ID: <1989Oct23.162453.29413@utzoo.uucp> Organization: U of Toronto Zoology References: <7279@sdcsvax.UCSD.Edu> Date: Mon, 23 Oct 89 16:24:53 GMT