Brown 888887 3.1 Campbell 235671 2.9
Student
in R5.h, which is
designed to be a node in a dynamically-allocated linked list of
students, and make a typedef for it.
char *
, the student ID as an
int
, and the GPA as a float
. The name
should be a pointer that gets dynamically-allocated.
malloc
or calloc
.
insert
that allocates and inserts
a node into the linked list. Initially you can insert nodes at the head or tail.
delete
that deletes a node
from the linked list, based on the name, and frees associated memory.
iterate
that iterates through
the nodes in order, calling the iterate function as defined in the header.
Brown (888887): 3.10 Campbell (235671): 2.90
readFile
that opens
data.txt
and reads the file, parsing one line at a
time with fscanf, calling insert for each line.
terminate
that
traverses the linked list, freeing the node, and the name it
contains, not necessarily in that order!
void readFile(char *filename); void insertStudent(char *name, int id, float gpa); void removeStudent(char *name); void iterate(iterate_function func); void terminate();
data.txt
. For example, the sample data.txt
has twenty lines, but you must not count on that in your program.
make package
command and submit to the Canvas drop box for R5.