C, Print Linked List of Strings

c, linked-list, printing

Solution

There are no stupid questions1. Here's some pseudo-code to get you started:

def printAll (node):
    while node is not null:
        print node->payload
        node = node->next

printAll (head)

That's it really, just start at the head node, printing out the payload and moving to the next node in the list.

Once that next node is the end of the list, stop.

1 Well, actually, there probably are, but this isn't one of them :-)

Problem

I have to write a C program that uses a linked list. I have created a list and added elements to the list. But I don't know how to print all the elements in the list. The list is a list of strings. I figured I'd somehow increment through the list, printing every string that's there, but I can't figure out a way to do this. Short: How to I print a `linked list`?

Original source