Okay I got that part working, but I get a minor problem. I just decided to keep it on this same thread though. Say I was in the middle of typing the answer when the time ran out. When it goes strait to the next question what I typed is still there
Code:
while(x<input){
bn=rand();
bn%=99;
bn+=1;
if(bn<=9)
bn+=10; /*bignum will always be 2 digits now*/
ln=rand();
ln%=10;
if(ln<2)
ln+=2;
printf("\t%5i\n\t*%4i\n\t-----\n\n",bn,ln);
FD_ZERO(&rfds);
FD_SET(0, &rfds);
tv.tv_sec = 6;
tv.tv_usec = 0;
retval=select(1, &rfds, NULL, NULL, &tv);
canswer=ln*bn;
if(retval){
fgets(buffer,sizeof buffer,stdin);
sscanf(buffer,"%d",&answer);
if((compare(answer,canswer))){
score++;
printf("Correct\n");
}
else{
printf("Wrong\n");
cscore++;
}
}
else{
printf("Wrong\n");
cscore++;
}
x++;
}
this is the loop I have. Any suggestions. Oh and compare is defined like so
Code:
int compare(int num1,int num2){
if(num1==num2)
return 1;
else
return 0;
}
Any ideas to fix this?