www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/09/08:11:11

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Centering printf text on a 80 column screen
Date: Tue, 08 Apr 1997 21:48:39 -0700
Organization: Alcyone Systems
Lines: 22
Message-ID: <334B1FA7.7CE2CF6@alcyone.com>
References: <334aed58 DOT 5263168 AT news DOT mindspring DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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.

printf has no functionality for this.  cprintf (a function, by the way, not
a keyword) doesn't either, as far as I know.

Probably the best solution is to write a centering function, which, when
passed a string and a width, will center that string in the width (or clip
it if it won't fit).  This is quite simple.

-- 
       Erik Max Francis, &tSftDotIotE / email:  max AT alcyone DOT com
                     Alcyone Systems /    web:  http://www.alcyone.com/max/
San Jose, California, United States /    icbm:  37 20 07 N  121 53 38 W
                                   \
                          "E pur, / sic muove!"
                                 / Galileo Galilei

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019