Preform the linked list nodes
Use free to clean up the memory
This commit is contained in:
parent
909f55f621
commit
ff0e21d42b
@ -287,12 +287,23 @@ again:
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
printf("\nSaved");
|
printf("\nSaved");
|
||||||
|
|
||||||
|
// reload data into linked list again
|
||||||
|
read_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_file()
|
void read_file()
|
||||||
{
|
{
|
||||||
// init head to null
|
// free the nodes
|
||||||
head = NULL;
|
// because it can be use in memory
|
||||||
|
// we need to clear it first
|
||||||
|
// before we re-initailize the new data
|
||||||
|
STUDENT *temp;
|
||||||
|
while (head != NULL) {
|
||||||
|
temp = head;
|
||||||
|
head = head->next;
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
file = fopen(FILE_STUDENT_DATA_PATH, "r");
|
file = fopen(FILE_STUDENT_DATA_PATH, "r");
|
||||||
|
Loading…
Reference in New Issue
Block a user