有人可以帮我fflush
在 C++ 中使用吗
这是C中的示例代码
#include <stdio.h>
using namespace std;
int a,b,i;
char result[20];
int main() {
scanf("%d %d\n", &a, &b);
for (i=1; i<=10; i++) {
printf("5\n");
fflush(stdout);
gets(result);
if (strcmp(result, "congratulation") == 0) break;
}
return 0;
}
这是获取交互式输入的程序。
我通常使用cin
,cout
所以可以不使用printf
andscanf
吗?