www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/10/13:50:27

From: Alain Magloire <alainm AT rcsm DOT ece DOT mcgill DOT ca>
Message-Id: <199905101750.NAA16951@mccoy2.ECE.McGill.CA>
Subject: Re: Quirky getch() (fwd)
To: djgpp-workers AT delorie DOT com
Date: Mon, 10 May 1999 13:50:04 -0400 (EDT)
In-Reply-To: <Pine.SUN.3.91.990510093704.2882J-100000@is> from "Eli Zaretskii" at May 10, 99 09:37:25 am
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Bonjour

> Since even stdio functions in the current implementation flush stdout
> when stdin is read in line-buffered mode, to prevent the FAQs like the
> one above, I thought it would be a prudent thing to make `getch' do
> the same.

Ok.
I was not being negative, but wanted to point the danger of some approach.
Let me put it in an other angle.  If the next libstdc++v3 do all the buffering
internally and does not use the FILE * handle as the underlying implementation
What will fflush() in getch() give you ? .. probably more questions.
IMHO, it is better, in the long run, to help write better and portable code.

But all that said, since getch() is already a non-portable OS specific
thing, they are already in trouble water so mine as well give the helping hand.
A better approach is to cout.flush() before mixing I/O API and let the internal
do the right thing.

Without the C++ overhead did you expect this to work :

printf ("hello world\n");
printf ("Enter key: ");
getch();

The last printf() was not flush, I did not expect it to show.

-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!

- Raw text -


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