Basic operations on a linked list in C