delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/20/15:36:44

From: oak9755 AT silver DOT sdsmt DOT edu (Olav Kindt)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Using getch() in DJGPP
Date: 20 Oct 1996 18:40:12 GMT
Organization: South Dakota School of Mines and Technology
Lines: 32
Distribution: world
Message-ID: <54drmc$qs4@news.sdsmt.edu>
References: <01bbbea6$206725e0$454fb7ce AT default>
NNTP-Posting-Host: silver.sdsmt.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

bitc (uh AT rt) wrote:
: Why doesn't the following function in DJGPP...
: 
: int main()
: {
: 	printf("Hello.");
: 	getch();
: }
: 
: Now, in every other compiler I've seen, the binary will run like this:
: 
: Hello. {keypress}{exit}
: 
: But when compiled under DJGPP, I get this:
: 
: {keypress}Hello. {exit}

Hi there,

DJGPP uses the unix style of buffered output (or so it seams). Bascially
this behaviour is correct, but annoying if you don't know about it. The
reasone is that stdout stream is line buffered, this means that all the
output to the screen is not sent to the stdout until a newline is entered.
In your program you can avoid this by setting a newline at the end out
your out putstring. "Hello\n". This will force the output to stdout at
once.

Hope this helps.

 -- Olav Kindt		     | email:	oak9755 AT silver DOT sdsmt DOT edu
737 E. Anamosa Street #103   |		xedb_oak AT debet DOT nhh DOT no
Rapid City SD-57701	     | 		MAIL me man.......

- Raw text -


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