Arm/linklist len

From ASMBits

In this problem, we will be working with a simple linked list. Each list element only contains a single word that is a pointer to the next node in the list. A pointer with value 0 (null pointer) indicates that the current node is the end of the list.

Write a function that will find the length of the linked list beginning at the node passed to the function as the first argument. A null pointer should return length 0. Do not attempt to detect cycles in the linked list (Cycles should cause your function to run forever.)

struct node { node *next; };
unsigned int listlen(node* list);

Expected solution length: Around 10 lines.

Sample Input

A -> B -> C -> null

Sample Output

3

Write your solution here

Upload a source file...