www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/08/15:48:40

Date: Sat, 8 May 1999 23:37:26 +0200
From: Alexander_Pankov <billy AT dkd DOT ot DOT lt>
X-Mailer: The Bat! (v1.31) UNREG
X-Priority: 3 (Normal)
Message-ID: <10984.990508@dkd.ot.lt>
To: Chong Kai Xiong <djgpp AT delorie DOT com>
Subject: Re: Quirky getch()
In-reply-To: <37306B66.BFCC4CDD@yahoo.com>
References: <37306B66 DOT BFCC4CDD AT yahoo DOT com>
Mime-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id PAA25033
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Hello Chong,

> Normally, we (at least I did :) would expect "Hello World" and "Sing
> along!" to be printed before the program pauses to wait for a keypress;
> The strange thing is, it doesn't. The program prints "Hello World" and
> then waits for a keypress before continuing to print "Sing along!". The
> problem can easily solved by replacing "getch();" with "Key = getch();"
> But why does it work this time? And the even stranger thing is that if I
> add a line feed i.e. "\n" at the end of the second output string, it
> works correctly too. Can anyone shed some light?

DJGPP's "cout <<" DO NOT PUT your string until it gets "\n" at the
end. It was made in order to speed up performance of output: in
protected mode realback calls (here is used DOS int 21h for output)
take a lot of time...

Best regards,
 Alexander_Pankov                            mailto:billy AT dkd DOT ot DOT lt

 * Origin: На С я могу писать ошибки, на С++ я могу их наследовать.


- Raw text -


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