Date: Sun, 31 Oct 1999 09:47:38 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: John G cc: djgpp AT delorie DOT com Subject: Re: Flush stdin? In-Reply-To: <38191ba8.20771109@news.ma.ultranet.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Thu, 28 Oct 1999, John G wrote: > >But a better solution would be to rewrite your code so that it doesn't > >*need* to empty the input buffer at all. Unfortunately, you didn't > >provide any details about why do you need to empty stdin, so it is > >impossible to give a more specific advice. > > Okay, this is the reason I need to empty the buffer. Say I input a > int with fscan then latter on input a character. That's your problem, right there: using `fscanf' for free-format input is a Bad Idea (tm). Use `fgets', and then process the string yourself, either with `sscanf' or with `strtol'. The latter is generally easier, since it returns a pointer to the unprocessed part of the string, which makes it easier to see what character confused it.