Thread: fflush(stdin);

  1. #1
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490

    fflush(stdin);

    is fflush(stdin) legal? the online docs i read all contradict each other.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > is fflush(stdin) legal?
    No.

    > the online docs i read all contradict each other
    There's only one doc which is worth reading in this respect, and it's the ANSI-C standard.
    You can get a free copy of the last C99 draft
    here

    If stream points to an output stream or an update stream in which the most recent
    operation was not input, the fflush function causes any unwritten data for that stream
    to be delivered to the host environment to be written to the file; otherwise, the behavior is
    undefined.
    Since stdin is never going to meet those conditions, fflush(stdin) is always undefined behaviour.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >But it is one nice topic for people like Prelude to pomp on.
    I try to rid the world of undefined behavior, thank you for noticing.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. fread/fwrite
    By chopficaro in forum C Programming
    Replies: 6
    Last Post: 05-11-2008, 01:48 AM
  3. Searching Into Files
    By St0rM-MaN in forum C Programming
    Replies: 12
    Last Post: 04-26-2007, 09:02 AM
  4. Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC
    By tvsinesperanto in forum C Programming
    Replies: 34
    Last Post: 03-11-2006, 12:13 PM
  5. Linked List Need Help Urgent
    By ykchua in forum C Programming
    Replies: 5
    Last Post: 08-17-2004, 02:57 PM