I'm preparing for interviews and I want to get comfortable with C after years of development in Java and C#. I decided to start with the implementation of basic data structures and this brings me to the LinkedList.
Program is:
Code:struct Node { struct Node* next; int data; }; struct LinkedList { struct Node* head; struct Node* tail; };Code:int main(int argc, char** argv) { struct LinkedList *list = NULL; printf("Declared the list"); LLInitialize(list); printf("Initialized the list"); }
Code:void LLInitialize(struct LinkedList *list) { list = (struct LinkedList*)malloc(sizeof(struct LinkedList)); list->head = NULL; list->tail = NULL; }
After the call to the LLInitialize() in the debugger I do not see the head/tail fields being NULL. They just are not there as if the malloc was never called. Why is that?



LinkBack URL
About LinkBacks


