Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 9383 8.86
- 2777 69.15
- 7793 83.35
- 5386 4.92
- 6649 14.21
- 2362 0.27
- 8690 0.59
- 7763 39.26
- 540 34.26
- 9172 57.36
- 5211 53.68
- 2567 64.29
- 5782 15.30
- 2862 51.23
- 4067 31.35
- 3929 98.02
- 4022 30.58
- 3069 81.67
- 1393 84.56
- 5011 80.42
- 6229 73.73
- 4421 49.19
- 3784 85.37
- 5198 43.24
- 8315 43.70
- 6413 35.26
- 6091 89.80
- 9956 18.73
- 6862 91.70
- 6996 72.81
- typedef struct student
- {
- double score;
- int id;
- char grades;
- } Student;
- void main(void)
- {
- char filename[] = "scores.dat";
- FILE *input;
- Student class[MAXNUM];
- int numScores;
- double average;
- input = fopen("scores.dat", "r");
- if (input == NULL)
- {
- printf("EOF");
- exit(1);
- }
- getScores(input, class[MAXNUM]);
- }
- int getScores(FILE *input, Student class[])
- {
- double s;
- int i, j, count = 0;
- while(fscanf(input, "%d %lf", &i, &s) == 2)
- {
- class[count].score = s;
- count++;
- }
- //loop to check what is in the array.
- for(j = 0; j< 20; j++){
- printf("%lfn", class[j].score);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement