In section 7.19.6.1 on ISO C specification, it says about a format
character "space". When and how we will use this "space" format? I mean
is there a usage, for e.g. like printf("%space",...); ?
Thanks,
Kannan
Are you looking at an HTML or text copy of the standard? In the real
PDF version, the string "space" is shown italicized, indicating that
it is not an ordinary character but stands for the blank (' ')
character.
Try running this program:
#include <stdio.h>
int main(void)
{
int x = 457;
int y = -457;
printf("%d%d\n", x, y);
printf("% d, % d\n", x, y);
return 0;
}
No flag prints positive and negative numbers as "457" and "-457"
respectively, which could cause columns not to line up in the output.
The '+' flag prints them as "+457" and "-457" respectively, which
causes numbers with the same number of digits to output the same
number of characters, for alignment, but you may not want the leading
'+' on positive numbers.
The ' ' flag prints them as " 457" and "-457", so they contain the
same number of characters, but adding a ' ' instead of a '+' to
positive value output.