Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!cs.utexas.edu!uunet!ncrlnk!ncr-sd!hp-sdd!ucsdhub!sdcsvax!beowulf!williams From: williams@beowulf.ucsd.edu (Paul Williamson) Newsgroups: comp.std.c Subject: printf zero-pads strings? Message-ID: <7279@sdcsvax.UCSD.Edu> Date: 21 Oct 89 23:52:30 GMT Sender: nobody@sdcsvax.UCSD.Edu Reply-To: williams@beowulf.UCSD.EDU (Paul Williamson) Distribution: na Organization: EE/CS Dept. U.C. San Diego Lines: 14 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. I know from my experiments with various compilers that it isn't safe to use this construct in the real world. But I can't help but wonder which compilers are right according to the current pANS. Language lawyers? Paul Williamson williams%cs@ucsd.edu