Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ames!dftsrv!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.std.c Subject: Re: printf zero-pads strings? Message-ID: <20327@mimsy.umd.edu> Date: 22 Oct 89 14:09:39 GMT References: <7279@sdcsvax.UCSD.Edu> Distribution: na Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 17 In article <7279@sdcsvax.UCSD.Edu> williams@beowulf.ucsd.edu (Paul Williamson) writes: > 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. (K&R2 is not a compiler.) The 4.4BSD doprnt.c (essentially the one I posted to comp.lang.c) prints "0000x". This appears to conform to the letter of the standard (we wrote the thing based on the letter of the standard!). -- `They were supposed to be green.' In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris