🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2603

Re: fflush(stdin) - not guaranteed to work?

#2603
From: News User Id
Date: Wed, 17 Apr 1996 01:44
26 lines
1775 bytes
In article <4ku3id$53h@solutions.solon.com>, c2a192@ugrad.cs.ubc.ca
(Kazimir Kylheku) writes:
> In article <4ksjpn$rjt@solutions.solon.com>,
> Himanshu Gohel <gohel@csee.usf.edu> wrote:
>> My question is, why?  Some of my students have written programs using
>> fflush(stdin) hoping it would clear away anything that's in the input
>> buffer before a scanf() statement and apparently it works on some PC
>> based compilers, but when re-compiled on a UNIX system, it does not
>> always work.
> 
> There is a detailed discussion in the comp.lang.c FAQ that
> covers VMS, UNIX and DOS in this respect, as far as I recall.

Before anyone goes off and looks and is disappointed (actually,
it's probably too late for that), the only system-specific
question that the comp.lang.c FAQ list answers in that much
detail is, "How do I read one character without waiting for
the RETURN key?".  To the implicit followon question, "If
fflush(stdin) won't work, how *can* I flush the user's typeahead
before issuing a prompt confirming whether I should reformat the
hard drive?", the FAQ list suggests no answer, because I don't
know a good one (other than, your program probably shouldn't be
offering to do that at all).

					Steve Summit
					scs@eskimo.com
Technical Details
Message-ID: <4l1idn$pvs@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4ksjpn$rjt@solutions.solon.com> <4ku3id$53h@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: News User Id <news@eskimo.com>
Newsgroups: comp.lang.c.moderated,comp.lang.c
Subject: Re: fflush(stdin) - not guaranteed to work?
Date: 16 Apr 1996 20:44:23 -0500
Organization: schmorganization
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4l1idn$pvs@solutions.solon.com>
References: <4ksjpn$rjt@solutions.solon.com> <4ku3id$53h@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Nntp-Posting-Host: eskimo.com