Microsoft C 5.1 question

Brandon S. Allbery allbery at ncoast.ORG
Sun Jan 29 03:43:43 AEST 1989


As quoted from <7026 at june.cs.washington.edu> by ka at 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 at ncoast.org
uunet!hal.cwru.edu!ncoast!allbery		    ncoast!allbery at hal.cwru.edu
      Send comp.sources.misc submissions to comp-sources-misc@<backbone>
NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser



More information about the Comp.lang.c mailing list