Use of fflush(stdin) in C

CProgrammingServer Side Programming

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
raja
Published on 08-Oct-2018 11:52:48
Advertisements