(a) 
typedef struct list_node {
  void* data; /* The data itself.  */
  struct list_node* next; /* The next element in the list.  */
} list_node;

(b) 
if ((int) x->next->data > 7)
  y->next = y->next->next;
if ((int) x->next->data % 2 == 0)
  x->data = ((int) x->data) + 4;

Example 9: Generic list in C. (a) Type definition; (b) sample code modifying a list node.

Back to Article