Computer >> Computer tutorials >  >> Programming >> C programming

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

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

Output

The string : Helloworld