大家给看一下,C的堆栈的问题
代码如下,我怎么都编译不了。
/*动态堆栈程序*/#include<stdio.h>#include<stdlib.h>struct stackNode { /*自引用结构*/int data;struct stackNode *nextPtr;};typedef struct stackNode STSCKNODE;typedef STSCKNODE *STSCKNODEPTR;void push(STSCKNODEPTR *,int);int pop(STSCKNODEPTR *);int isEmpty(STSCKNDOEPTR);void printStack(STSCKNODEPTR);void instructions(void);void main(){ STSCKNODEPTR stackPtr=NULL; /*指向栈顶*/ int choice,value; instructions(); printf("?"); scanf("%d",&choice); while(choice!=3) { switch(choice) { case 1: /*把值压入堆栈*/ printf("Enter an integer:"); scanf("%d",&value); push(&stackPtr,value); printStack(stackPtr); break; case 2: if (!isEmpty(stackPtr)) printf("The popped value is %d.\n",pop(&stackPtr)); printStack(stackPtr); break; default: printf("Invalid choice:\n\n"); instructions(); break; } printf("?"); scanf("%d",&choice); } printf("End of run.\n");}/*打印菜单指令*/void instructions(void){ printf("Enter choice:\n" "1 to push a vlaue on the stack\n" "2 to pop a value of the stack\n" "3 to end program.\n");}/*在栈顶插入一个结点*/void push(STACKNODEPTR * topPtr,int info){ STACKNODEPTR newPtr; newPtr=malloc(sizeof(STACKNODE)); if(newPtr!=NULL) { newPtr.data=info; newPtr.nextPtr=*topPtr; *topPtr=newPtr; } else printf("%d not inserted.No memory available.\n",info);}/*删除栈顶结点*/int pop(STACKNODEPTR *topPtr){ STACKNODEPTR tempPtr; int popValue; tempPtr=*topPtr; popValue=(*topPtr).data; *topPtr=(*topPtr).nextPtr; free(tempPtr); return popValue;}/*打印堆栈*/void printStack(STACKNODEPTR currentPtr){ if (currentPtr==NULL) printf("The stack is empty.\n\n"); else { printf("The stack is:\n"); while(currentPtr!=NULL) { printf("%d-->",currentPtr.data); currentPtr=currentPtr.nextPtr; } printf("NULL\n"); }}/*堆栈为空*/int isEmpty(STACKNODEPTR topPtr){ return topPtr==NULL;}