From the course: Master C Language Pointers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Removing structures - C Tutorial
From the course: Master C Language Pointers
Removing structures
- [Instructor] Structures are managed in a linked list by manipulating their pointers. To remove a structure, the previous item in the list skips over it, referencing the following item. The structure is then unlinked or lost, and its memory freed. This exercise file creates a linked list of five items. The fill function at line 32 helps automatically build the list. In the main function the list is created in the for loop at line 62. The list is output at line 84. Starting at line 88, the fourth structure is removed from the list. This process involves adjusting the pointer stored in the third structure, which was now skip over the fourth structure and reference the fifth structure. The while loop at line 92 adjust the current pointer, so that it references the third structure in the list just before the structure to remove. The weird statement at line 104 copies the next pointer from the fourth structure in the list…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Understanding a linked list2m 20s
-
(Locked)
Implementing a linked list3m 36s
-
(Locked)
Removing structures4m 3s
-
(Locked)
Adding structures3m 3s
-
(Locked)
Creating a double-linked list2m 57s
-
(Locked)
Saving a linked list3m 4s
-
(Locked)
Challenge: Manage a linked list2m 13s
-
(Locked)
Solution: Manage a linked list2m 26s
-
-