Can someone help me using fflush in C++
Here is a sample code in 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;
}
This is program for getting interactive input.
I usually use cin and cout so is it possible not using printf and scanf?
The translation to C++ programming style is this:
Note that I deliberately added some error checking.