www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/05/09:13:06

Message-Id: <515C083001E72A00@iris.ernet.in>
Date: 04 Nov 96 18:45 IST
From: tehmul%NIITPUN AT iris DOT ernet DOT in
Sender: tehmul%niitpun AT iris DOT ernet DOT in
To: djgpp AT delorie DOT com
Subject: Re: Using getch() in DJGPP
Mime-Version: 1.0

                              
 
bitc wrote:
>>
>> Why doesn't the following function in DJGPP...
>> int main()
>> {
>>         printf("Hello.");
>>         getch();
>> }
>> [snip] when compiled under DJGPP, I get this:
>> {keypress}Hello. {exit}
>>
> AFAIK it's because stdout is buffered. Turn out buffering of stdout and it
> should work fine (But I can't remember how to do it)..

I think you got to use setvbuf or setbuf.  I forgot myself.  But you could
always do this instead.
     printf( "Hello." );
     fflush( stdout );
     getch();

Incidentally, if you'd used an stdio function like say, getchar(); to pause
for input, it would have remembered to send pending output to the screen.

TG

- Raw text -


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