Thread: can someone explain me why fflush(stdin) is bad?

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    3

    can someone explain me why fflush(stdin) is bad?

    thanks

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Same reason that pushing with a rope, doesn't work well.

    Stdin is an input buffer, not an output buffer. fflush() was made to work with output buffers (with some compilers, it will work at times, but it's non-standard) and not reliable.

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    The technical answer is that the C standard states that you can only flush output streams. This means that the result of fflush(stdin) is undefined and will probably result in different behavior depending on what platform you are working on.
    bit∙hub [bit-huhb] n. A source and destination for information.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bad coding habits
    By Magos in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-12-2005, 05:44 PM
  2. Poker bad beats
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 01-15-2005, 11:42 PM
  3. Shocking(kind of)
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 12-10-2002, 08:52 PM
  4. good news and bad news
    By Garfield in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 10-27-2001, 07:31 AM
  5. Bad code or bad compiler?
    By musayume in forum C Programming
    Replies: 3
    Last Post: 10-22-2001, 09:08 PM