У меня проблема с тем, что мой цикл перестает читать файл после завершения. Как я могу заставить его остановиться после последней строки и перейти к следующей строке кода? Кроме того, я хотел бы, чтобы инкрементированный балл останавливался с циклом и окончательный результат записывался в файл, может ли кто-нибудь помочь? СпасибоОстановка в конце файла
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;