CITS2002 Systems Programming  
prev
next CITS2002 CITS2002 schedule  

Declaring a list of items

Let's develop a similar data structure that, unlike the first-in-last-out (FILO) approach of the stack, provides first-in-first-out (FIFO) storage - much fairer for queueing at the ATM!

We term such a data structure a list, and its datatype declaration is very similar to our stack:


 typedef struct _l {
     char        *string;
     struct _l   *next;
 } LISTITEM;

 LISTITEM   *list  =  NULL;

As with the stack, we'll need to support empty lists, and will again employ a NULL pointer to represent it.

This time, each data item to be stored in the list is string, and we'll often term such a structure as "a list of strings".

 


CITS2002 Systems Programming, Lecture 19, p9, 3rd October 2023.