[ back to toc ]

C Output Syntax

Date: 2002/01/22 15:20

Hi Peter,
I am a student at UCD and I was wondering how to right justify a line of
text output using the printf statement. I have three columns of data that
I need to justify. I'm using the built in Unix Compiler from the Mandrake
kernel. Thankx.


you can use the function printf. To right justify, you have to know to
what character position to jsutify the something you want to print. For


prints the character 1 on the 80. position. The same is true for strings.

To left justify you have to use the - modifier, like


which prints 1 and 79 spaces. Experience with this and type

man 3 printf

at the Mandrake command prompt to get the manual. "man printf" actually
does not work, because there is a printf command in the shell and that is
the default man page. You need the function.


[ back to toc ]