Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!ginosko!uunet!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.std.c Subject: Re: printf zero-pads strings? Message-ID: <1470@crdos1.crd.ge.COM> Date: 25 Oct 89 18:22:47 GMT References: <7279@sdcsvax.UCSD.Edu> <20327@mimsy.umd.edu> <1430@crdos1.crd.ge.COM> <20371@mimsy.umd.edu> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Distribution: na Organization: GE Corp R&D Center Lines: 24 In article <20371@mimsy.umd.edu>, chris@mimsy.umd.edu (Chris Torek) writes: if a precision is specified, the |0| flag will be ignored. (quoted from the standard) This certainly doesn't grab me as being 'least astonishment.' I interpret this to mean that if I say %010.2f the |0| is ignored. Yes? My copy of the standard is on loan, I can't check that you quoted it correctly, but the context (from which I extracted it) doesn't seem to refer to this. Could someone explain why this works this way? I certainly find it easier to explain when leading zero means pad with zeros. Period. What was the thinking that specifying precision in some way made zero fill undesirable? Adding a leading zero is not the type of thing one does by accident. It would be nice if it had been defined to either cause leading zeros or be a runtime error. Ignoring a user request for action is a good way to create hard to find errors (my opinion). -- bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen) "The world is filled with fools. They blindly follow their so-called 'reason' in the face of the church and common sense. Any fool can see that the world is flat!" - anon