Is fflush(stdin) undefined?

This is a discussion on Is fflush(stdin) undefined? within the C Programming forums, part of the General Programming Boards category; So fflush(stdin) is undefined? Because my c programming book uses it as a way to clear the input buffer. (The ...

  1. #1
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046

    Is fflush(stdin) undefined?

    So fflush(stdin) is undefined?

    Because my c programming book uses it as a way to clear the input buffer. (The book: Sams Teach Yourself C in 21 Days, 4th edition.)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,669
    Sams Teach Yourself C in 21 Days - Review

    In fact, it seems to be the worst book on C I have ever seen.
    And that's the 5th edition!

    Got any tables with a short leg?

    gg

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    MSDN fflush I thought it worth noting that while fflush(stdin) in not standard, it's not 'always' wrong.

    Regards,
    Brian

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Sure, while we're at it, you use void main in Java. However, that wasn't the question. The question was is it standard. The answer is: no. End of discussion.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    And that's the 5th edition!
    4th, actually. You misread my post. But I agree with you.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,669
    The review was of the 5th edition.

    >> And that's the 5th edition!
    My comment was based on the assumption that edition N+1 is typically better than edition N.
    But in this case, I can see how the 5th edition may actually be worse than the 4th.

    gg

  8. #8
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    Quote Originally Posted by quzah
    The question was is it standard.
    Somehow I don't see anything about 'standard' in the OP

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well you're just an idiot then. The term "defined" in reference to programming, specifically the C language, is "as defined by the standard". Therefore, the term "undefined" means "not defined by the standard". So perhaps you're not an idiot, just ignorant. Now, unless you really are an idiot, you have no excuse. If you are an idiot, you're at least an informed one now.


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    Quote Originally Posted by quzah
    The term "defined" in reference to programming, specifically the C language, is "as defined by the standard".
    Does the name calling make you feel bigger and better? I'm sure you'd like me to get all upset and come unglued on the forum. I don't accept your definition of "defined". Better go work on your coding and interpersonal skills instead of your post count flames. BK

  11. #11
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Quote Originally Posted by Br5an
    Does the name calling make you feel bigger and better? I'm sure you'd like me to get all upset and come unglued on the forum. I don't accept your definition of "defined". Better go work on your coding and interpersonal skills instead of your post count flames. BK
    I'd say quzah's correct. Trying to define "defined" any other way makes it completely useless. A compiler could be written that gives defined behavior to negative array subscripts, but that in no way makes negative array subscripting a defined operation in general. Whether or not you accept this is a personal issue.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  12. #12
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Quote Originally Posted by Br5an
    MSDN fflush I thought it worth noting that while fflush(stdin) in not standard, it's not 'always' wrong.

    Regards,
    Brian
    Sure, if you don't care about writing portable code, and always plan on using the same compiler.

  13. #13
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Br5an
    Better go work on your coding and interpersonal skills instead of your post count flames. BK
    I'm supposed to care what you think why again? Also, I've yet to see anything wrong with my coding. When someone noteworthy points it out, I'll pay attention. Until then, sod off, as they say.


    Quzah.
    Hope is the first step on the road to disappointment.

  14. #14
    Registered User
    Join Date
    Jul 2005
    Posts
    69
    Yeah, and I'm going to stop writting WinAPI because it's not 'defined' by ANSI / ISO. BK

  15. #15
    ---
    Join Date
    May 2004
    Posts
    1,379
    Quote Originally Posted by Br5an
    Yeah, and I'm going to stop writting WinAPI because it's not 'defined' by ANSI / ISO. BK
    That is completely different. It is an API not a 'standard library'.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 09:18 AM
  4. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 11:02 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21