Date: Mon, 3 Nov 1997 16:34:00 +0200 (IST) From: Eli Zaretskii To: John Estess cc: djgpp AT delorie DOT com Subject: Re: PLEASEHELPgetchar In-Reply-To: <01bce705$d5229f40$12d01ace@pjestess> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On 1 Nov 1997, John Estess wrote: > In an example, the DJGPP compiler blazes right through these three lines > without yn picking up the input value. I know this because I inserted a > print statement right after the second line and after the third (curious). Please download the DJGPP FAQ list (v2/faq210b.zip from the same place you got DJGPP) and look in its Table of Contents and/or the index at the end, before posting questions. This question is discussed in section 9.4 of the FAQ. The problem is that output is buffered, and the FAQ explains how to write such code correctly. > I also tried the getche fuction with the conio.h library, but it acted the > same. Since getche was supposed to be an unbuffered function, I was less > than impressed. Try harder. The problem is not with input buffering, but with output buffering. Use `cprintf' instead of `printf' (on of the solutions suggested by the FAQ). > According to the "Joy of C" and the reference book for PowerC, this > should work. Hell, it was given to > us as an example of how to do it! WAAAAAHHHH! Now you know the true value of that book and the person who wrote the example ;-). > fflush (stdin) ; According to ANSI C Standard, `fflush' has no effect on input streams. In particular, with DJGPP you won't see any effect whatsoever. `fflush' is only defined for output streams.