my code is to show a few questions that are contained in a file when the user select the option to. But i'm facing this problem: After de program show 2 questions it always shows only the last line of my file. I don't know what is wrong.
Here is the code (only de case 1 of the switch menu)
printf("\nThe selected subject was Geology");
while(continue != 0)
{
r=0;
srand(time(NULL));
r = rand()%7;
printf("\n%d", r);
if(r==0)
r=1;
for(i=0; i<r; i++)
fscanf(arqgeo, "%s %s %s %s %s %c", question, alta, altb, altc, altd, &respa);
printf("\n\n%s \n%s \n%s \n%s \n%s \n", question, alta, altb, altc, altd);
printf("Enter alternative: ");
setbuf(stdin,NULL);
scanf("%c",&resp);
if(arqgeo == NULL)
{
printf("An error has occurred\n");
printf("Contact the developers !!!\n");
} else {
if(resp == respa)
{
printf("You're right!!!\n");
pont++;
printf("\n\n\n");
} else {
puts("\a");
printf("You missed!!!");
printf(" The correct answer is: %c", respa);
erro++;
printf("\n\n\n");
}
}
printf("Do you wish to continue? Enter a number other than 0 ");
scanf("%d", &continue);
}
break;
where: "respa" is the right answer, "alta-d" is the alternatives, "resp" is the answer of the user, "arqgeo" is the file that contain the questions
--sorry for the bad english--