Mail Archives: djgpp/1997/04/09/18:01:51
void center_print( char *mystring, short field_width )
{
short center;
center = ((1 + field_width) - strlen(mystring))/2;
printf( "%*.*s%s\n", center, center, " ", mystring );
}
How's that? The function will print any string centered in a
'field_width' wide zone beginning at the current cursor position on the
screen. You can substitute fprintf, sprintf, or cprintf as needed.
Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com
On Wed, 9 Apr 1997 dabrownz AT mindspring DOT com wrote:
> How do you center printf text on a DOS screen? I can't find anyway to
> do this other than using tabs and spaces (very annoying). What is the
> 'correct' way to do it? Do I have to use 'cprintf' or some other
> keyword or include another library? I'd would really appriciate any
> help, Thanks.
>
- Raw text -