← Back to list

Fflush in C

The function fflush is used for flushing the stream’s output buffer; that is, it is used to immediately flush the contents present in any…

Amansingh Javatpoint · 2021-05-08 12:52 · 0 claps · 0.9 min read
#fflush #c
Open on Medium ↗

Fflush in C

The function fflush is used for flushing the stream’s output buffer; that is, it is used to immediately flush the contents present in any of the buffered stream to the corresponding file. It will return zero if successful, else it returns EOF, and the error indicator will be a set, such as feof.

Syntax:

1

2

3

int fflush (FILE * stream)

where;

Stream — pointer to a FILE object that specifies a buffered stream.

Stream points to an output stream or an update stream in which operation was not an input. Fflush causes any unwritten data of that stream to be delivered to the other host environment to be written into the file; else will cause undefined behavior.

Fflush will write the contents of the stdout buffer immediately to the output file instead of a newline buffered writing by default. This should not be used on any of the input streams as it is prone to undefined behavior. Fflush(stream) is defined as output streams; hence, fflush(stdout) will work fine, but fflush(stdin) does not.

Consider an instance that includes fflush(stdin):

include <stdio.h>

include <conio.h>

include <string.h>

int main()

{

char s[20] = “JavaTPoint”;

printf (“The string is: %s”, s);

fflush(stdin);

return 0;

}

[embed]Fflush in C - Tutorial And Example The function fflush is used for flushing the stream's output buffer; that is, it is used to immediately flush the…www.tutorialandexample.com


메타데이터
post_id
bd6f71bd0d3e
slug
fflush-in-c-bd6f71bd0d3e
url
https://medium.com/@amansingh-javatpoint/fflush-in-c-bd6f71bd0d3e
canonical_url
https://medium.com/@amansingh-javatpoint/fflush-in-c-bd6f71bd0d3e
author_url
https://medium.com/@amansingh-javatpoint
status
ok
fetched_at
2026-07-28 07:50:17