如何清空输入流的缓冲区?要求能跨平台
我知道Windows下用fflush,Linux下用setbuf。但是两者都不能移植。谁能介绍个办法清空输入流的缓冲区,
在Windows和Linux都能通用哦。。
2011-11-28 21:06
程序代码:
#include <stdlib.h>
#include <stdio.h>
int main()
{
char a, b;
scanf("%c", &a);
while (fgetc(stdin) != '\n')
NULL;
b = getchar();
printf("%c\t%c\n", a, b);
return 0;
}

2011-11-28 21:14