Im getting crashes if I initialize more than one stack using this code.
I am initializing in Main usingCode:struct stackNode{ int data; struct stackNode *nextptr; }; int pop(struct stackNode **topptr) { struct stackNode *tmp; if( *topptr != NULL) { tmp = *topptr; *topptr = (struct stackNode *) tmp->nextptr; int temp2; temp2 = tmp->data; free(tmp); return temp2; } else{ printf("Pop function error."); exit(0); } } void push(struct stackNode **topptr, int info) { struct stackNode *temp; temp = (struct stackNode *)malloc(sizeof(struct stackNode)); temp->data = info; temp->nextptr = *topptr; *topptr = temp; }
Code:struct stackNode **xstack; struct stackNode **ystack;
if I only initialize one I don't crash until I try to use the second initialized stack.



LinkBack URL
About LinkBacks


