From: Tudor Newsgroups: comp.os.msdos.djgpp Subject: Re: getch() and getche() Date: Sun, 19 Jan 1997 19:08:51 -0800 Organization: Communications Accesibles Montreal Lines: 50 Message-ID: <32E2E1C3.4E03@cam.org> References: <32E251B8 DOT 1C3E AT dmv DOT com> <32E29D1A DOT B63 AT bc DOT sympatico DOT ca> Reply-To: tudor AT cam DOT org NNTP-Posting-Host: dynamicppp-202.hip.cam.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp eblazecka wrote: > > Pyro Technic wrote: > > > > 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-- > > > > the output is weird. your given a blank screen. if U procede as if the > > message had appeared( push 'Y' for instance) then 'Y' is diplayed > > followed by "Y for yes or N for No: ". weird > > > > although if it is written like this > > --code segment-- > > cout << "Y for yes or N for No:\n"; //note the \n addition > > answer = getche(); > > ..... > > --end-- > > > > then the message gets displayed, but Y is on the next line. > > > > tanx, > > Pyro > Not too sure, haven't used cout in awhile, but I think if you just do > cout << "blah blah blah" << flush; > or > cout.flush(); > and then do getche it might work. I think this is normal behaviour because DJGPP uses buffered I/O so the thing you write to the screen appears only when you flush the buffer or put a newline char on the line. -- tudor 'at' cam 'dot' org yoda69 'at' hotmail 'dot' com http://www.cam.org/~tudor -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS d-(--) s(-):(+) a? C+ UL>++++ P L>+++++ E- W++ N o K---(----) w--- O---- M-- V-? PS+++ PE Y PGP t+ 5-- X+++>++++ R tv b+ DI D+ G e->++ h>++ r- y>+++++ ------END GEEK CODE BLOCK------