![]() |
| | #1 |
| Registered User Join Date: Nov 2009
Posts: 3
| can someone explain me why fflush(stdin) is bad? |
| newbiecr is offline | |
| | #2 |
| Registered User Join Date: Sep 2006
Posts: 3,157
| 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. |
| Adak is offline | |
| | #3 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 3,020
| 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. |
| bithub is offline | |
| | #4 |
| and the Hat of Ass Join Date: Dec 2007
Posts: 814
| |
| rags_to_riches is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bad coding habits | Magos | General Discussions | 14 | 09-12-2005 05:44 PM |
| Poker bad beats | PJYelton | A Brief History of Cprogramming.com | 21 | 01-15-2005 11:42 PM |
| Shocking(kind of) | Shadow | A Brief History of Cprogramming.com | 25 | 12-10-2002 08:52 PM |
| good news and bad news | Garfield | A Brief History of Cprogramming.com | 25 | 10-27-2001 07:31 AM |
| Bad code or bad compiler? | musayume | C Programming | 3 | 10-22-2001 09:08 PM |