更新时间:2021-08-03 01:31:55
我可以看到几个问题:
1)当您将stackPtr
的地址传递给push函数时,printStack(&stack);
应该为printStack(stackPtr);
.
1) printStack(&stack);
should be printStack(stackPtr);
as you are passing address of stackPtr
to the push function.
2)
node = (StackNodePtr)malloc(sizeof(StackNodePtr));
应为:
node = malloc(sizeof(StackNode));
3)
push(stackPtr, 'a');
应为:
push(&stackPtr, 'a');
您需要传递顶部指针的地址.
As you need to pass the address of the top pointer.