data-structures · beginner · ~15 min
Walk a linked list using a pointer that advances along `->next`.
Given
typedef struct node { int data; struct node *next; } node_t;
implement int list_length(const node_t *head) returning the number of nodes (0 for NULL).
int list_length(const node_t *head) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.