Thread: flushing stdin

  1. #1
    Registered User
    Join Date
    Apr 2006

    flushing stdin

    I prompt for input and the scanf function is skipped over because the stdin buffer contains data. How can I flush this beforehand? Everywhere I look tells me it's system dependent and I'm on linux and ncurses is recommended. There surely has to be a way in ansi c to do this.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    This is a frequently asked question (hint hint).
    My best code is written with the delete key.

  3. #3
    Registered User 00Sven's Avatar
    Join Date
    Feb 2006
    LINKDon't double post.
    Windows XP Home Edition - Dev-C++
    Quote Originally Posted by "The C Programming Language" by Brian W. Kernignhan and Dennis M. Ritchie
    int fflush(FILE *stream)
    On an output stream, fflush causes any buffered but unwritten data to be written; On an input stream, the effect is undefined. It returns EOF for a write error, and zero otherwise. fflush(NULL) flushes all output streams.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Flushing buffer
    By $l4xklynx in forum C Programming
    Replies: 6
    Last Post: 03-04-2009, 10:07 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. flushing stdin
    By crash88 in forum C Programming
    Replies: 2
    Last Post: 06-29-2006, 08:55 PM
  4. flushing stdin
    By crash88 in forum Linux Programming
    Replies: 1
    Last Post: 05-18-2006, 01:21 AM
  5. stdin question
    By oomen3 in forum C Programming
    Replies: 6
    Last Post: 02-19-2003, 02:52 PM