473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What does fflush(stdin) do?

hi,
what is the use of fflush(stdin) in c programing.


regards,
santosh
Jun 7 '10 #1
2 17205
. This function is used to flush any data in output stream. So this will compile but its behavior is undefined by the ANSI C standard. The fflush() function is only meant to be used on streams open for output, not input. Both fflush(stdin) and fflush(NULL), in some C libraries, will flush stdout and stderr, but this is completely unportable! Thus, it should not be used.
Jun 7 '10 #2
Banfa
9,065 Expert Mod 8TB
As mayankarpit says fflush is defined by the standard to work on output streams. If called on an input stream or a bi-directional stream thats last operation was input the behaviour is undefined.

So compiler/platforms support fflush(stdin) as an extension but using it makes the code non-portable and getting into the habit of using it could result in your getting unusual problems if you switch to a platform for which the operation is truly undefined.

There is lots of information about this on the web so do a search and it will throw up plenty of useful links like this.
Jun 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: praba kar | last post by:
Dear All, I am new to Python. I am in need of some sorting functions (eg) numerical sorting functions and alphapetical sorting functions. I have searched through net But I cannot find any...
6
by: praba kar | last post by:
Dear All, I have doubt regarding sorting. I have a list that list have another list (eg) list = ,,] I want to sort only numeric value having array field. How I need to do for that.
1
by: praba kar | last post by:
Dear all, I have doubt regarding python Compilation. I want to know whether Python is compiler language or interpreted language. If Python is interpreter language why compilation is there. ...
3
by: darkstorm | last post by:
I have a doubt regarding inheritance involving templates Consider this: ///////////////////////////////////// template<typename T> class A { private: T m_a;
6
by: Luca | last post by:
I have a doubt: is it dangerous to create widgets out of the main thread, or it is dangerous to call methods of a widgets out of the thread which created it? or both? TIA Perry
5
by: meenu_susi | last post by:
doubt regarding select box....urgent in the below code i am getting data from database..according to the condition.. i want the available data in database to get displayed in selectbox.. for...
3
by: meenu_susi | last post by:
doubt regarding shopping cart...in asp i have a page where user purchase the product.. here i have the product as tshirt.. and for ex..i have shirt sizes as follows s m l xl xxl and...
38
by: edu.mvk | last post by:
Hi I am using strcpy() in my code for copying a string to another string. i am using static char arrays. for the first time it is exected correctly but the second time the control reaches...
4
by: SandyIsCool | last post by:
Hi, I am newbie to asp.net. I have small doubt regarding page life cycle. MSDN documentaion says that init event does blhah, blah load event does blah blah etc. But Id ont see any init or load...
8
by: somenath | last post by:
Hi All, I have a doubt regarding the pointer assignment . Please have a look at the following program . #include<stdio.h> #include<stdlib.h> #define NAMESIZE 10 #define SAFE_FREE(t) if(t)\...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.