C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-04-2009, 12:18 PM   #1
Registered User
 
Join Date: Nov 2009
Posts: 3
can someone explain me why fflush(stdin) is bad?

thanks
newbiecr is offline   Reply With Quote
Old 11-04-2009, 12:22 PM   #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   Reply With Quote
Old 11-04-2009, 12:24 PM   #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   Reply With Quote
Old 11-04-2009, 12:39 PM   #4
and the Hat of Ass
 
Join Date: Dec 2007
Posts: 814
It's right in our FAQ!
rags_to_riches is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 12:52 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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