I am new to C programming language
i am trying to implement linked list using C
but i found that error CrtIsValidHeapP ointer(pUserDat a)
i don't know what is it
my code
i know that there is lot of things that is not implemented efficiently but now i am focusing only on this error
thanks in advance
i am trying to implement linked list using C
but i found that error CrtIsValidHeapP ointer(pUserDat a)
i don't know what is it
my code
Code:
struct node { int value; struct node * next; }; void addNode(struct node * t) { t->next = (struct node *)malloc(sizeof(struct node)); if(t->next != NULL) { (t->next)->value = 5; (t->next)->next = NULL; } else { printf("FATAL ERROR NO MEMORY"); } } int main(array<System::String ^> ^args) { struct node * p; struct node head; head.value = 1; head.next = NULL; p = & head; addNode(p); while(p != NULL) { printf("%d\n",(*p).value); p = (*p).next; } p = &head; free(p->next); p->next = NULL; free(p); p = NULL; return 0; }
thanks in advance
Comment