Xref: utzoo comp.lang.c:15861 comp.sys.ibm.pc:23857 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!hal!ncoast!allbery From: allbery@ncoast.ORG (Brandon S. Allbery) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Microsoft C 5.1 question Message-ID: <13368@ncoast.ORG> Date: 28 Jan 89 17:43:43 GMT References: <104@rpi.edu> <198@broadway.UUCP> <6951@june.cs.washington.edu> <1587@csuna.UUCP> <7026@june.cs.washington.edu> Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery) Followup-To: comp.lang.c Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 26 As quoted from <7026@june.cs.washington.edu> by ka@june.cs.washington.edu (Kenneth Almquist): +--------------- | These behave identically. A fair number of years ago, AT&T decided to | switch from the "%02d" format to the "%.2d" format. A couple of reasons | for this may be: | | 1) Conceptual simplicity. The printf format has a precision field | for use by the %s and the floating point formats; it makes sense | to use this same field for integer formats rather than ignoring | the precision and using some other method of getting zero padding. | | 2) Flexibility. Using the precision to specify the zero padding | allows the field width to be used for its normal function even | when zero padding is desired. +--------------- One other reason as well: it's not possible to get zero padding when using variable width fields (%*d) under the old scheme. With the new scheme, use %.*d for zero padding and %*.*d to choose zero padding or none at runtime. ++Brandon -- Brandon S. Allbery, moderator of comp.sources.misc allbery@ncoast.org uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu Send comp.sources.misc submissions to comp-sources-misc@ NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser