www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/27/18:15:20

From: "Bryan Russell" <BRYAN-R AT mis DOT scitec DOT com DOT au>
Organization: SCITEC LIMITED
To: jkeene AT unlinfo DOT unl DOT edu (Jon Keene), djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Tue, 28 Feb 1995 09:28:15 +1100
Subject: Re: Question reagarding kbhit()
Return-Receipt-To: "Bryan Russell" <BRYAN-R AT mis DOT scitec DOT com DOT au>

> Could anyone tell me why it is that when I run the following
> program, it pauses for the keyboard hit _before_ doing any output?
> 
> Ponderously yours,
> Rumball
> ---
> 
> #include <stdio.h>
> #include <pc.h>
> #define BUFSIZE 1840  /* (80 * 23) */
> #define BLANK ' '
> 
> main () {
> 
>         int i;
>         int buf[BUFSIZE];
> 
>         for ( i = 0; i < BUFSIZE; i++ )
>                 buf[i] = BLANK;
>         buf[0] = 'a';
>         buf[BUFSIZE - 1] = 'z';
>         for ( i = 0; i < BUFSIZE; i++ )
>                 printf("%c", buf[i]);
>         while (!kbhit()) 
>                 ;
>         return 0;
> }
> 

I've also found this and came to the, perhaps wrong, conclusion that printf 
uses a buffered output. If you use cprintf instead it should display at the 
expected places.


 

Bryan Russell                      Net : bryan-r AT mis DOT scitec DOT com DOT au
Technical Support Specialist     Phone : +61 2 428 9570    _--_|\
SCITEC LIMITED                     Fax : +61 2 428 9988   /      \
3 Apollo Place, Lane Cove, NSW 2066                       \_.--._*
AUSTRALIA                                                       v

- Raw text -


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