Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. struct date {
  4. int day, month, year;
  5. };
  6.  
  7. struct student {
  8. int studentID;
  9. char firstName[20];
  10. char lastName[20];
  11. char courseID[10];
  12. int year;
  13. struct date registrationDate;
  14. struct date dateOfBirth;
  15. int averageGrade;
  16. };
  17.  
  18. void main() {
  19. FILE* fpo;
  20. fpo = fopen("Output.txt", "r");
  21. char c;
  22. int count = 0;
  23.  
  24. for (c = getc(fpo); c != EOF; c = getc(fpo))
  25. if (c == '\n')
  26. count = count + 1;
  27. printf("The file contains %d students\n ", count);
  28.  
  29.  
  30. struct student studentArray[100];
  31.  
  32. static char buffer[1024];
  33.  
  34. while (fgets(buffer, 1024, fpo) != NULL) {
  35. puts(buffer);
  36. }
  37. fclose(fpo);
  38.  
  39.  
  40. /*
  41. struct date registrationDate = { 27, 01, 2020 };
  42. struct date dateOfBirth = { 31, 01, 2000 };
  43. struct student s = {
  44. 123,
  45. "Gavin",
  46. "Guthrie",
  47. "AX250",
  48. 2002,
  49. registrationDate,
  50. dateOfBirth,
  51. 1
  52. };
  53. printf(s.year);
  54. */
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement