C linked nodes and traversal

A node contains a value and a pointer to the next node. NULL ends the chain. The arrow operator accesses a field through a pointer.

C
#include <stdio.h>
struct Node { int value; struct Node *next; };
int main(void) {
    struct Node third = {30, NULL};
    struct Node second = {20, &third};
    struct Node first = {10, &second};
    for (struct Node *current = &first; current != NULL; current = current->next) {
        printf("%d\n", current->value);
    }
    return 0;
}
Read the full lesson