Thread: Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC

  1. #31
    Registered User
    Join Date
    Mar 2006
    Location
    Antwerp, Belgium
    Posts
    9
    So what about scanf("%*[^\n]%*c"); as fflush(stdin); ?

    The students running linux had to use this command.
    Windows students could pick which one they liked because the Borland compiler allowed it to.
    Last edited by Enira; 03-11-2006 at 10:26 AM.

  2. #32
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by Enira
    So what about scanf("%*[^\n]%*c"); as fflush(stdin); ?
    http://groups.google.com/group/comp....c2a8270de88382
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #33
    Registered User
    Join Date
    Mar 2006
    Location
    Antwerp, Belgium
    Posts
    9
    Quote Originally Posted by Dave_Sinkula
    Weird
    DevC++ confirms this but my Borland does not.
    In Borland it is just the same as a flush.

    Anyway it can't hurt to seperate them knowing that it will decrease the rate of failing.
    Last edited by Enira; 03-11-2006 at 11:55 AM.

  4. #34
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    I thought this little bit
    A tiny function that calls getchar() in a loop may be more readable to future programmers:
    really brought us full circle back to the FAQ.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #35
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    That's like saying "gets() works for me, most of the time".
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A place to start - mac or pc?
    By GCat in forum C++ Programming
    Replies: 12
    Last Post: 11-19-2004, 12:21 PM
  2. Mac programming?
    By Luigi in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 02-07-2003, 09:37 PM