#include #include struct list { int node; struct list *next; }; int sum(const struct list *x) { if (x == NULL) return 0; else return x->node + sum(x->next); } int main(void) { /* Is there no shorter way? */ struct list node3 = { 3, NULL }; struct list node2 = { 2, &node3 }; struct list node1 = { 1, &node2 }; struct list *llist = &node1; printf("%d\n", sum(llist)); /* Just to make sure llist wasn't modified. */ printf("%d\n", sum(llist)); return EXIT_SUCCESS; }