Mail Archives: djgpp/1999/09/13/10:31:44
On Thu, 9 Sep 1999, Thone wrote:
> scanf("%c", &ch);
> scanf("%c", &ch);
> the computer will wait for user input data for one time.
> so I asked someone about that and he told me to put
> ffluch(stdin) between those two lines.So I do that and it's
> ok when I use Borland C++ compiler.But when i use
> DJGPP it still have the same problem,
`fflush's effect is only defined for output streams. What Borland
does with "fflush(stdin);" is an unportable extension; you shouldn't
rely on it.
If you want to write code that reads characters one at a time, don't
use buffered input functions, they always read an entire line. Use
library function `getch' or `getkey' instead.
- Raw text -