www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/27/12:08:49

From: Dan Nelson <dnelson AT xnet DOT com>
Subject: Re: Question reagarding kbhit()
To: djgpp AT sun DOT soe DOT clarkson DOT edu (djgpp)
Date: Mon, 27 Feb 1995 09:22:57 -0600 (CST)

/* Note to whoever maintains the DJGPP list:  
/
   Could you please add a 'Reply-to: djgpp AT sun DOT soe DOT clarkson DOT edu' line to
   your mail headers?  This list defaults to the sender of the mail, not the
 / list, and I have to redirect every response I make back to the list..
*/

in the last episode, Jon Keene said:
> 
> 
> Could anyone tell me why it is that when I run the following
> program, it pauses for the keyboard hit _before_ doing any output?

[code snipped]
>         for ( i = 0; i < BUFSIZE; i++ )
>                 printf("%c", buf[i]);
>         while (!kbhit()) 
>                 ;
>         return 0;
> }

You didn't flush your buffer.  do a fflush(stdout); just before the kbhit().

-Dan Nelson       //      /\ /\/\ | (_, /\   Some people think MS-DOS is a
                \X/                          necessary evil.  They are wrong. 
dnelson AT xnet DOT com     dan AT nccseq DOT noctrl DOT edu   MS-DOS is *not* necessary.

- Raw text -


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