Date: Sat, 8 May 1999 23:37:26 +0200 From: Alexander_Pankov X-Mailer: The Bat! (v1.31) UNREG X-Priority: 3 (Normal) Message-ID: <10984.990508@dkd.ot.lt> To: Chong Kai Xiong Subject: Re: Quirky getch() In-reply-To: <37306B66.BFCC4CDD@yahoo.com> References: <37306B66 DOT BFCC4CDD AT yahoo DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=Windows-1251 Content-Transfer-Encoding: 8bit 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 Precedence: bulk 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: На С я могу писать ошибки, на С++ я могу их наследовать.