I need some tricks. I'm a student and I cant get the output of my C programs to line up in colunms.
Using Turbo C and a dot matrix printer.
Printable View
I need some tricks. I'm a student and I cant get the output of my C programs to line up in colunms.
Using Turbo C and a dot matrix printer.
This can sometimes be tricky. I would try printing out the table or whatever the output is to 'standard output' stdout first. That way you can see what it looks like in the console window. You can use tabs \t and I think backspaces \b to try to line up the columns. You can also try to incorporate column widths like so %20s in the format string.
While you can use formating features such as /n /b and /t
You can also format how much space between screen imput etc.. is displayed, these are called field Width specifiers..
i.e
^ denotes a space
printf("%d", 12345 ) Output = 12345
printf("%2d", 12345 ) Output = 12345
printf("%8d", 12345 ) Output = ^^^12345
printf("%08d", 12345 ) Output = 00012345
printf("%-2d", 12345 ) Output = 12345
printf("%-10f", 3.8) Output = 3.800000^^
printf("%-10.3d", 3.8) Output = 3.800^^^^^^
Hope this helps.
-ali