Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. struct student_s {
  2.     char name[MAX_NAME_SIZE];
  3.     int age;
  4.     Student* next;              // Pointer to next student in a list
  5. };
  6.  
  7. typedef struct student_s Student;
  8.  
  9. Student* readStudents(FILE *file)
  10. {
  11.     Student* first = NULL;     // Pointer to the first student in the list
  12.     Student* last = NULL;      // Pointer to the last student in the list
  13.     Student* student = readOneStudent(file);
  14.     while (student != NULL) {
  15.         if (first == NULL) {
  16.             first = last = student;   // Empty list case
  17.         } else {
  18.             last->next = student;
  19.             last = student;
  20.             first = last;
  21.         }
  22.         student= readOneStudent(file);
  23.     }
  24.     return first;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement