Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: 2 stupid pondering programming questions

Author: Alessandro Scotti

Date: 15:31:37 09/17/04

Go up one level in this thread


On September 17, 2004 at 18:04:48, martin fierz wrote:

>can somebody tell me why fflush(stdin) won't work?

As a function, fflush() belongs to the C library. If used on an input stream it
will flush any input that was read and buffered, but not yet delivered. For
example, you call fgetc() to get one byte, but the library may actually read 20
bytes from the stream, although it only delivers the first to you. If so,
calling fflush() discards the 19 bytes that the library has buffered.
In your case though, you are calling PeekNamedPipe which is an OS function. It
tells you that there is input, but it is in the system buffer not in the
library's. So, calling fflush() has nothing to do because you haven't read any
data yet.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.