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.
Implementing a linked list - C Tutorial
From the course: Master C Language Pointers
Implementing a linked list
- This code shows a structure that can grow into a linked list but I want to start simply. The first function is input. It processes standard input, removing the new line, you can examine it at your leisure. In the main function starting at line 39, the item structure has four members, integer ID, string name, float price, and next, a pointer to another item structure. Two structure pointer variables are declared at line 47, first and current. The third pointer required is in the structure itself, next. The structures memory is allocated at line 51, saved in variable first, the base of the list. The first structure then becomes the current structure at line 59. Starting at line 62, the structure is filled. The next pointer is set to null at line 69, as this structure is the first, last, and only structure in the list. Line 72 outputs the structures contents. Build and run. And apples are a dollar 20 a pound.…
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
-
-