[comp.lang.c] question about format strings

PEPRBV%CFAAMP.BITNET@husc6.harvard.EDU (Bob Babcock) (12/22/87)

Reading the description of the format string for printf, it seemed
to me that "%10 " might be the equivalent of 10X in Fortran, that
is, insert 10 spaces.  I tested this on my MS-DOS C and it worked, but
on my OS-9/68K C it did not.  Which of these is correct, or is this a
detail which can legally vary?  (Both compilers claim to implement
K&R C, not ANSI C.)

ark@alice.UUCP (12/23/87)

In article <10954@brl-adm.ARPA>, PEPRBV%CFAAMP.BITNET@husc6.harvard.EDU writes:
> Reading the description of the format string for printf, it seemed
> to me that "%10 " might be the equivalent of 10X in Fortran, that
> is, insert 10 spaces.

"%10 " is an illegal format string.

A blank space is a format modifier, like 'l', that says that you want
printf to write a space in place of a sign when the number is
zero or positive. However, it has to have something to modify.
So, for instance "%g" will print 3 as "3" and -3 as "-3", but
"% g" will print 3 as " 3" and -3 as "-3".