Step 4
That's a pretty nice linked list you got there! But let's test the dynamic nature of a
linked list. In arrays, if you want to delete an element, you either have to resize the array
and copy its contents back and forth, or swap some elements and ignore others. No fun either
way. So let's delete an element the linked list way--by calling Delete(). Don't worry, it's
already written for you.
- In lab12.c, uncomment the lines of code that prompt and get an id
number from the user to delete from the class list.
- In lab12.c, uncomment the lines of code that attempt to delete a student with
the entered id.
- Call PrintList() to verify that the list shrunk correctly.
Moving on to Step 5...
linux1[19]% gcc -Wall -ansi -c lab12.c
linux1[20]% gcc lab12.o linkedlist.o
linux1[21]% a.out data.txt
Welcome to the last lab of the semester! :)
David's Section :
First Name Last Name ID Grade
-------------------- -------------------- ------------ -------
Ann Lewis 123 98%
Mark Johnson 345 78%
Justin Lewis 122 99%
Bob Ramsey 141 64%
Julia's Section :
First Name Last Name ID Grade
-------------------- -------------------- ------------ -------
Joseph Eisenhower 212 82%
Gary Watson 532 92%
Jamie Casselman 621 100%
Claire Dishon 161 76%
Aafreen's Section :
First Name Last Name ID Grade
-------------------- -------------------- ------------ -------
Mary Jones 634 85%
Jenny Garcia 121 87%
Samantha Warrez 124 86%
Delete a student from who's section ?
1 - David
2 - Julia
3 - Aafreen
Please enter the section number: 2
Please enter the id# to delete from the list: 621
Student was successfully deleted from class list.
First Name Last Name ID Grade
-------------------- -------------------- ------------ -------
Joseph Eisenhower 212 82%
Gary Watson 532 92%
Claire Dishon 161 76%
linux1[22]%