Newsgroups: comp.std.c
Path: 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

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
