Use of fflush(stdin) in C


The function fflush(stdin) is used to flush the output buffer of the stream. It returns zero, if successful otherwise, returns EOF and feof error indicator is set.

Here is the syntax of fflush(stdin) in C language,

int fflush(FILE *stream);

Here is an example of fflush(stdin) in C language,

Example

 Live Demo

#include
#include
int main() {
   char s[20] = "Helloworld";
   printf("The string : %s", s);
   fflush(stdin);
   return 0;
}

Output

The string : Helloworld

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 24-Jun-2020

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements