🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #823

printf zero-pads strings?

#823
From: Paul Williamson
Date: Sat, 21 Oct 1989 23:52
14 lines
1197 bytes
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
Technical Details
Message-ID: <7279@sdcsvax.UCSD.Edu>
Path: arc1-ca.pugleaf.net!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

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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