J'ai un problème pour que ma boucle arrête de lire le fichier après la fin. Comment puis-je l'arrêter après la dernière ligne et passer à la ligne de code suivante? Je voudrais aussi que le score incrémenté s'arrête avec la boucle et que le résultat final soit écrit dans un fichier. Quelqu'un peut-il m'aider? MerciArrêt à la fin du fichier
do {
system("cls");
i = 0;
printf("\tPortal Examination\n\tEnter Faculty name.:");
fflush(stdin);
scanf("%s", f_name);
printf("\n\tEnter Course.:");
fflush(stdin);
scanf("%s", course_text);
printf("\n\tEnter ID.:");
fflush(stdin);
scanf("%s", r_query);
k = strlen(r_query);
strcat(f_name,"101stud.txt");
strcat(course_text,"101exam.txt");
f_course = fopen(f_name, "rb");
system("cls");
printf("\tPortal Examination");
printf("\n\n..:: Searching for '%s' \n===================================================\n",r_query);
while (fread(&stud, sizeof(stud), 1, f_course) == 1) {
for (j = 0; j <= k; j++) {
s_rollno[j] = stud.stud_rollno[j];
}
s_rollno[j]='\0';
if (stricmp(s_rollno,r_query) == 0) {
system("pause");
//*****write exams****
f_exam = fopen(course_text, "rb");
while (fread(&numbers, sizeof(numbers), 1, f_exam) != EOF) {
system("cls");
printf("\n\tAnswer all Questions:\n\t%s\n\t",numbers.question);
fflush(stdin);
scanf("%s", a_query);
if (stricmp(numbers.answer, a_query) == 0)
s_result += 5;
printf("%s has %d score\n\t", r_query, s_result);
system("pause");
}
break;
i++;
if (i % 4 == 0) {
printf("..::Press any key to continue...");
getch();
}
}
}
if (i == 0)
printf("\n..::No match found!");
else
printf("\n..:: %d match(s) found.",i);
fclose(f_course);
printf("\n..:: Search Again?\n\n\t[1] Yes\t\t[0] No\n\t");
scanf("%d",&ch);
} while (ch == 1);
break;