Ooh! Here's a good brainteaser. You've got a linked list of integers, for instance:
You're given a pointer to the head of the list. For instance:
You need to remove the *first* element of the list. You may not change the function signature (prototype). Remember that C is call-by-value. How would you do it?
/* This is equivalent to the structure and typedefs in the previous code posting */
typedef struct NodeStruct {
int data;
struct NodeStruct* next;
} Node, *List;
You're given a pointer to the head of the list. For instance:
void func_you_write(List A) {
}
You need to remove the *first* element of the list. You may not change the function signature (prototype). Remember that C is call-by-value. How would you do it?
