fflush(stdin) 함수는 스트림의 출력 버퍼를 플러시하거나 지우는 데 사용됩니다. scanf() 이후에 사용되면 입력 버퍼도 플러시합니다. 성공하면 0을 반환하고, 그렇지 않으면 EOF를 반환하고 feof 오류 표시기가 설정됩니다.
다음은 C 언어에서 입력 버퍼를 지우는 fflush(stdin) 구문입니다.
int fflush(FILE *stream);
다음은 C 언어에서 입력 버퍼를 지우는 fflush(stdin)의 예입니다.
예시
#include <stdio.h>
#include<stdlib.h>
int main() {
char s[20];
printf("Enter the string : \n", s);
scanf("%s\n", s);
printf("The entered string : %s", s);
fflush(stdin);
return 0;
} 출력
다음은 출력입니다.
Enter the string : helloworld The entered string : helloworld