In this assignment, you further extend Project 5/6 (reading the acars.bin file u
ID: 3693169 • Letter: I
Question
In this assignment, you further extend Project 5/6 (reading the acars.bin file using structs) to replace the array with a singly-linked list. Create a new version of your Project 5 program, the one that reads the acars.bin file, so that instead of storing the structs in an array, you dynamically allocate each struct, and add them to a linked list that you create. So the logic of your program looks like: create two pointers to your struct. One is called head, and the other tail. open the acars.bin file malloc the first struct read the file into that struct make head point to that struct make tail point to that struct while not end-of-file on the acars file: malloc a new struct read the next struct from acars.bin into the structure you malloc'ed. Add that struct to your linked list, using the next_ptr member of the struct set tail to point to the element you just added repeat the loop Starting at head, traverse the list, printing the elements of each structure. Your struct should now look like this: typedef struct acars_struct { char flight[7] ; char dest[5] ; char origin[5] ; int dateTimeStamp ; struct acars_struct* next ; } AcarsStruct ; This is exactly like your definition for the struct in Project 5, except that a pointer named next has been added. This pointer is used to "string together" successively-allocated structs in the linked list. The head pointer points to the first element of the list, and the tail pointer will point to the last element of the list. In this assignment, you further extend Project 5/6 (reading the acars.bin file using structs) to replace the array with a singly-linked list. Create a new version of your Project 5 program, the one that reads the acars.bin file, so that instead of storing the structs in an array, you dynamically allocate each struct, and add them to a linked list that you create. So the logic of your program looks like: create two pointers to your struct. One is called head, and the other tail. open the acars.bin file malloc the first struct read the file into that struct make head point to that struct make tail point to that struct while not end-of-file on the acars file: malloc a new struct read the next struct from acars.bin into the structure you malloc'ed. Add that struct to your linked list, using the next_ptr member of the struct set tail to point to the element you just added repeat the loop Starting at head, traverse the list, printing the elements of each structure. Your struct should now look like this: typedef struct acars_struct { char flight[7] ; char dest[5] ; char origin[5] ; int dateTimeStamp ; struct acars_struct* next ; } AcarsStruct ; This is exactly like your definition for the struct in Project 5, except that a pointer named next has been added. This pointer is used to "string together" successively-allocated structs in the linked list. The head pointer points to the first element of the list, and the tail pointer will point to the last element of the list. In this assignment, you further extend Project 5/6 (reading the acars.bin file using structs) to replace the array with a singly-linked list. Create a new version of your Project 5 program, the one that reads the acars.bin file, so that instead of storing the structs in an array, you dynamically allocate each struct, and add them to a linked list that you create. So the logic of your program looks like: create two pointers to your struct. One is called head, and the other tail. open the acars.bin file malloc the first struct read the file into that struct make head point to that struct make tail point to that struct while not end-of-file on the acars file: malloc a new struct read the next struct from acars.bin into the structure you malloc'ed. Add that struct to your linked list, using the next_ptr member of the struct set tail to point to the element you just added repeat the loop Starting at head, traverse the list, printing the elements of each structure. Your struct should now look like this: typedef struct acars_struct { char flight[7] ; char dest[5] ; char origin[5] ; int dateTimeStamp ; struct acars_struct* next ; } AcarsStruct ; This is exactly like your definition for the struct in Project 5, except that a pointer named next has been added. This pointer is used to "string together" successively-allocated structs in the linked list. The head pointer points to the first element of the list, and the tail pointer will point to the last element of the list.Explanation / Answer
Output: