473,396 Members | 1,968 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 is the exact functionality of fflush(stdin) or fflush(stdout)?

Siddarth777
many times i encountered these two functions,especially i have used them in socket programming in unix environment
but i just have a vague idea regarding functionality of those two functions
THE IDEA WHICH AM HAVING IS:
they are used to clear input and output buffer

but am not having a faintest idea regarding how they actually work

please help me
thanks a lot in advance
Nov 12 '10 #1
1 6297
Banfa
9,065 Expert Mod 8TB
How they work is implementation defined and on many platforms fflush(stdin); is undefined behaviour and is defined by the standard as such.

A few platforms provide fflush(stdin); as an extension to the standard but if you are writing portable programs you should avoid fflushing an input stream or an inout stream after it has been used for input.

fflush(stdout); ensures that all buffered output for stdout is written to stdout before the function returns. Like I said how it is done is platform dependent and I would not worry about it. If you do get an answer it will only apply to the platform that the answer is given for.
Nov 13 '10 #2

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

Similar topics

0
by: Christophe HELFER | last post by:
hi, I have some problem with redirecting input and output from a process. I can only use VB language (sorry...) Situation: I have to use the Cisco Network Registrar (DNS And DHCP server) ...
0
by: lickspittle | last post by:
Hi, I have Python embedded with my other code, and when my other code opens a console and redirects stdout, stdin and stderr to it, then calls PyRun_InteractiveLoop, it immediately returns with...
8
by: max(01)* | last post by:
hi. i was wondering, what's the simplest way to echo the standard input to the standard output, with no modification. i came up with: .... while True: try:
5
by: | last post by:
Maybe I ask something OS depended but maybe not. So I ask: I want to run an external program from my C++ program. I want stdin of external program constructed from a C++ string in my program....
6
by: Andrew | last post by:
Hello, I have read about stdin and stdout being standard input and output streams, but I am still having trouble visualizing how they really work and what they contain during program execution....
5
by: hugo27 | last post by:
hugo 27, Oct 9, 2004 Ref Docs: c.l.c FAQ article 12.26 . www.digitalmars.com sitemap.stdio.fflush Reading these Docs I understand that fflush does not summarily destroy or discard the...
1
by: Pravin Prabhu | last post by:
Hi, Can the 'stdin' and 'stdout' streams point to a Network socket? I have a socket connection from Windows to UNIX, can I set the two streams to point to the socket connection to send/receive...
3
by: leahw25 | last post by:
I'm a complete novice at c programming. I was wondering what would be the best way to read in roman numerals and convert them into decimal values. I tried the switch statement but it told me that the...
4
by: xman | last post by:
I'm looking for a C/C++ library that can get access to the stdin and stdout of a process. I may invoke a external program in a C/C++ program, but how do write data into the stdin of the external...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.