delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/07/19:16:34

Date: Thu, 7 Jan 1999 19:16:21 -0500 (EST)
From: Daniel Reed <djr AT narnia DOT n DOT ml DOT org>
To: MstrX1 <mstrx1 AT aol DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Newbie, stupid 'printf' Question
In-Reply-To: <19990107175907.21430.00007885@ng-fp1.aol.com>
Message-ID: <Pine.LNX.4.05.9901071914310.29337-100000@narnia.n.ml.org>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On 7 Jan 1999, MstrX1 wrote:
) if I don't type a LF("\n") at the end of my printf-text
) the text isn't printed correctly under MS-DOS.
) Most times this isn't a problem, because I need 
) it anyway, but if I want to print text at the bottom 
) of the screen and I print (printf("Hello World\n")),
) the screen scrolls down and the top-line will be destroyed.
) 
) How can I print it correctly without using a "\n" at the end,
) or stop this scrolling ?
Either use setvbuf() (I believe) to take stdout from cooked mode
(buffered) into raw mode (unbuffered), or simply use
	printf("Hello World");
	fflush(stdout);
fflush() will cause anything in the buffer for a FILE * to be written to
the actual file it's attached to, which has the effect of causing your
text to be printed without having to add in a \n.

-- 
Daniel Reed <n AT ml DOT org>
I either want less corruption, or more chance to participate in it. -- Ashleigh Brilliant

- Raw text -


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