Hello all,
I've got the start of a linked list program here that compiles without issue, but crashes when it is run. Here's the code:
The program doesn't crash when the printf statement is commented out, which I find very confusing. Can somebody please explain what is going on? By the way, I'm running Windows XP and using Visual C++ 2008 to compile.Code:#define _CRT_SECURE_NO_WARNINGS #define STRING_LENGTH 16 #include <stdio.h> #include <stdlib.h> struct LL_node{ char name[STRING_LENGTH]; struct LL_node *prev; struct LL_node *next; }; typedef struct LL_node NODE; int main() { NODE *head, *curr, *tail; head = NULL; tail = NULL; /* initialize first node */ curr = (NODE *)malloc(sizeof(curr)); (curr->name)[0] = '\0'; curr->prev = head; curr->next = tail; printf("End of program"); return 0; }
Thanks,
amac