delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/21/15:18:32

From: "David May" <dmay AT tvi DOT cc DOT nm DOT us>
Organization: Albuquerque T-VI
To: invid AT dmv DOT com
Date: Tue, 21 Jan 1997 12:58:00 -0700
Subject: Re: getch() and getche()
CC: djgpp AT delorie DOT com
Message-ID: <A5DE9A6243@tvi_mail.tvi.cc.nm.us>

> i don't no if NE1 else has noticed this but there is a very annoying
> featire with getch() and getche(). as a newbie i'd much appreciate NE1
> who could point out how to fix it.
> 
> Here's the problem.
> 
> --code segment--
>  cout << "Y for yes or N for No: ";
>  answer = getche();
>  ......
> --end--

This has to do with buffering of the I/O.  I don't know how to fix it 
using standard streams for C++, but for C I/O, use
  fflush (stdout)
after the prompt "Y for yes or N for No: " is printed.
Alternately, you can use the console (conio.h) I/O functions.

Hope this helps.
David May, ID Card Administrator
Albuquerque TVI

- Raw text -


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