Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. 9383 8.86
  2. 2777 69.15
  3. 7793 83.35
  4. 5386 4.92
  5. 6649 14.21
  6. 2362 0.27
  7. 8690 0.59
  8. 7763 39.26
  9. 540 34.26
  10. 9172 57.36
  11. 5211 53.68
  12. 2567 64.29
  13. 5782 15.30
  14. 2862 51.23
  15. 4067 31.35
  16. 3929 98.02
  17. 4022 30.58
  18. 3069 81.67
  19. 1393 84.56
  20. 5011 80.42
  21. 6229 73.73
  22. 4421 49.19
  23. 3784 85.37
  24. 5198 43.24
  25. 8315 43.70
  26. 6413 35.26
  27. 6091 89.80
  28. 9956 18.73
  29. 6862 91.70
  30. 6996 72.81
  31.  
  32. typedef struct student
  33. {
  34. double score;
  35. int id;
  36. char grades;
  37. } Student;
  38.  
  39.  
  40. void main(void)
  41. {
  42. char filename[] = "scores.dat";
  43. FILE *input;
  44. Student class[MAXNUM];
  45. int numScores;
  46. double average;
  47.  
  48. input = fopen("scores.dat", "r");
  49.  
  50. if (input == NULL)
  51. {
  52. printf("EOF");
  53. exit(1);
  54. }
  55. getScores(input, class[MAXNUM]);
  56. }
  57.  
  58.  
  59. int getScores(FILE *input, Student class[])
  60. {
  61. double s;
  62. int i, j, count = 0;
  63.  
  64. while(fscanf(input, "%d %lf", &i, &s) == 2)
  65. {
  66. class[count].score = s;
  67. count++;
  68. }
  69. //loop to check what is in the array.
  70. for(j = 0; j< 20; j++){
  71. printf("%lfn", class[j].score);
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement