What is Difference b/w fflush(stdin) and fflush(stdout) in C/C++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is Difference b/w fflush(stdin) and fflush(stdout) in C/C++?

Fflush is used in buffer? Now what is buffer and what is stdout? Clear Details Needed?

4th Dec 2016, 8:23 AM
Rahul Vashisth
Rahul Vashisth - avatar
2 Answers
0
buffer is some amount of memory allocated for communication between the terminal and your program which are two different process running in the system the terminal takes all the data you have entered until enter button is pressed once the enter button is pressed it takes the data you have entered and places it in the buffer memory . your program takes the data required from this memory and uses it . when it wants to print something in the terminal it writes the data into buffer memory and the terminal takes the data from the buffer memory and prints it. some compiler clears the data in buffer memory after use otherwise we need to do manually by using fflush fflush is used to clear the data inside this memory so that it can be used to write new data into it
16th Dec 2016, 4:19 PM
Vijeth Belle
Vijeth Belle - avatar
0
stdout and stdin are two standard output and input files . when your program wants to print something it's writes into stdout which is nothing but buffer memory in this case you can change the destination of the stdout to some txt or other format files in which you want to store the output of your program same thing for stdin you can change the path of stdin if you want your program to take input data from some file instead of the terminal
16th Dec 2016, 4:24 PM
Vijeth Belle
Vijeth Belle - avatar