From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Trouble with getche() Date: Wed, 09 Oct 1996 09:02:41 +0100 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 44 Message-ID: <325B5C21.41C6@LSTM.Ruhr-UNI-Bochum.De> References: <325B1E56 DOT 5BDA AT erols DOT com> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de 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 Tony Sideris wrote: > > I'm trying to do this simple little C thing, but it won't work right...I > copied it right out of a C book. > Here's what I type: > main() > { > char ch; > printf("Type a character: "); Just add fflush(stdout); > ch = getche(); > printf("\nYou typed: %c", ch); > } > > After I compile it, I run it and the cursor just goes to next line > (which is blank) and does nothing. Then, for example, I type p it says: > > pType a character: > You typed: p Welcome in the UNIXish world of buffered streams. stdout is usually flushed when it encounters a \n (or when you printout n characters not equal \n, where n is typically 16384) The second line is only printed because the exit() function flushes and closes (?) stdout. Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * Voice/Fax Box: +49 2561 91371 2056 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************