delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/13/23:02:53

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: char getch(void)
Date: Tue, 13 Jan 1998 19:22:15 -0800
Organization: Alcyone Systems
Lines: 37
Message-ID: <34BC2F67.7799C508@alcyone.com>
References: <34bbe72b DOT 4606230 AT news2 DOT frankfurt DOT netsurf DOT de>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Bjoern Appel wrote:

> #include<stdio.h>
> #include<conio.h>
> 
> int main(void)
> {
>   clrscr()
>   printf("Please wait...");
>   getch();
>   return 0;
> }
> //end of little program **********
> 
> Now the problem:
> The program shows a blank screen and will print the "Pleas wait..."
> AFTER I pushed a button, not BEFORE !!!
> 
> What could I do ?

stdout is line buffered, so it will not display printed text without a
newline unless you explicitly flush it.

But there's a bigger issue, which you will invariably run into in more
unpleasant ways if you continue:  conio and stdio I/O routines are not
intended to be used simultaneously (this in general holds for any I/O
manager, such as curses, etc.).  Instead you should be using one or the
other.  Since you want to do screen clears, you should use conio only --
use cprintf instead of printf.

-- 
         Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                       Alcyone Systems / http://www.alcyone.com/max/
  San Jose, California, United States / icbm://+37.20.07/-121.53.38
                                     \
                       "Life may be / the product of imperfections."
                                   / (Marclo Gleiser)

- Raw text -


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