0
How to centralized the output on C language without spamming \t or \n?
C languange
2 Answers
+ 2
Use a number to indicate the width that you want the output to take. If the number is positive the output will be right justified in the width you gave, if it's negative the output will be left justified.
EXAMPLE:
int x=0, y=1;
printf("%5d%5d\n", x, y);
printf("%-5d%-5d\n", x, y);
OUTPUT:
0 1
0 1