Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2002 15:47:09 -0700
From:      Clint Olsen <clint@0lsen.net>
To:        echo dev <echo_dev@hotmail.com>
Cc:        hackers@freebsd.org
Subject:   Re: your mail
Message-ID:  <20020523224709.GA77003@0lsen.net>
In-Reply-To: <F107VCxPcnietfhTGBe00009c91@hotmail.com>
References:  <F107VCxPcnietfhTGBe00009c91@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On May 23, echo dev wrote:
> is there anyone that might know why the fflush did not work???? I fugre
> this works besuse it shoves an empty vale into the buffer thus casuseing
> it to be empty.....

From the C-FAQ - http://www.eskimo.com/~scs/C-faq/top.html

12.26:  How can I flush pending input so that a user's typeahead isn't
        read at the next prompt?  Will fflush(stdin) work?

A:      fflush() is defined only for output streams.  Since its
        definition of "flush" is to complete the writing of buffered
        characters (not to discard them), discarding unread input would
        not be an analogous meaning for fflush on input streams.

        There is no standard way to discard unread characters from a
        stdio input stream, nor would such a way necessarily be
        sufficient, since unread characters can also accumulate in
        other, OS-level input buffers.  You may be able to read and
        discard characters until \n, or use the curses flushinp()
        function, or use some system-specific technique.  See also
        questions 19.1 and 19.2.

        References: ISO Sec. 7.9.5.2; H&S Sec. 15.2.

-Clint

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020523224709.GA77003>