Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- FILE *inputFile = fopen("students.txt", "r");
- char endLineChar;
- int i = 0, amountStudents = 1;
- while (!feof(inputFile)){
- endLineChar = fgetc(inputFile);
- if (endLineChar == '\n')
- amountStudents++;
- }
- struct studentInfo {
- long group;
- char name[20];
- int firstExam;
- int secondExam;
- int thirdExam;
- int fourthExam;
- int fifthExam;
- };
- struct studentInfo students[amountStudents];
- while (!feof(inputFile)) {
- fscanf(inputFile, "%li %s %d %d %d %d %d", &students[i].group, students[i].name, &students[i].firstExam, &students[i].secondExam, &students[i].thirdExam, &students[i].fourthExam, &students[i].fifthExam);
- i++;
- }
- fclose(inputFile);
- //printf("%s", students[0].name);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement