z158晚点吗:flushall();这是什么函数啊

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/02 20:12:54

flushall函数:
功 能: 清除所有缓冲区
用 法: int flushall(void);
程序例:

#include <stdio.h>

int main(void)
{
FILE *stream;

/* create a file */
stream = fopen("DUMMY.FIL", "w");

/* flush all open streams */
printf("%d streams were flushed.\n",
flushall());

/* close the file */
fclose(stream);
return 0;
}

如果你使用的语言,没有这个系统自带函数那么肯定是编程者自己写的函数

scanf对流的操作遵从类型匹配操作原则,如果类型不匹配,它将不读取输入流。因此输入流将滞留,如果输入流不空,scanf不会等待用户输入,解决办法就是手动清除输入流,可用flushall()函数实现。