delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/01/01:40:29

Xref: news2.mv.net comp.os.msdos.djgpp:3287
From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Odd printf behaviour
Date: 30 Apr 1996 02:08:52 GMT
Organization: The National Capital FreeNet
Lines: 28
Sender: ao950 AT freenet2 DOT carleton DOT ca (Paul Derbyshire)
Message-ID: <4m3snk$40@freenet-news.carleton.ca>
References: <199604240928 DOT NAA08434 AT video DOT yars DOT free DOT net> <4m2fva$qo1 AT minerva DOT ibernet DOT es>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet2.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Fernando Marcos (fmarcos AT jet DOT es) writes:
> "Alexander V. Lukyanov" <lav AT video DOT yars DOT free DOT net> wrote:
> 
>>> I wrote some simple code that utilizes the gotoxy() and printf() 
>>> statements to place text on the screen, ala:
>>> When I run this type of code nothing appears on the screen.  I can see 
>>> the cursor jumping around, but nothing else.  However, if I include a 
>>> '\n' in the printf statement, things display fine, *or* as soon as I 
>>> printf with a '\n' outside the loop, then **all** the text gets 
>>> displayed.  It's almost as if it's being buffered, and isn't displayed 
>>> until a '\n' comes along.
> 
> That is because you need to fflush(stdout) after you write a string 
> without a trailing "\n". It is a normal printf() "feature".
> 
I've seen this myself. Printf buffers things. Use cprintf, if you want to
avoid the \n and the problems this may cause on the bottom screen line.
Cprintf also enables colored text and backgrounds. On the other hand the
text it produces isn't captured by DOS redirection commands, i.e. to
printer or to a file (I don't think it is anyways...?)


--
    .*.  "Clouds are not spheres, mountains are not cones, coastlines are not
 -()  <  circles, and bark is not smooth, nor does lightning travel in a
    `*'  straight line."    ,------------------------------------------------
         -- B. Mandelbrot  |  Paul Derbyshire (PGD) ao950 AT freenet DOT carleton DOT ca

- Raw text -


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