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

Implementing a linked list - C Tutorial

From the course: Master C Language Pointers

Start my 1-month free trial

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.…

Contents