编译错误哪里错误了呢 请大佬分析下
#include<stdio.h>#include<stdlib.h>
#include<malloc.h>
typedef int bool;
typedef struct Node{
int data;
struct Node * pNext;
}NODE,*PNODE;
typedef struct Stack{
PNODE pTop;
PNODE pBottom;
}STACK,*PSTACK;
//函数声明
void init(PSTACK pS);//初始化
void push(PSTACK pS,int val);//压栈
void traverse(PSTACK pS);//遍历输出栈
bool empty(PSTACK pS);//判断是否栈为空
void pop(PSTACK,int *);//出栈
void clear(PSTACK pS);//清空栈
int main(void){
STACK S;
int val=0;
init(&S);//完成初始化,目的就是造出一个空栈
push(&S,1);//压栈
push(&S,2);
push(&S,3);
push(&S,4);
push(&S,5);
push(&S,6);
traverse(&S);
if(pop(&S,&val)){
printf("出栈成功,出栈的数是%d\n",val);
}
else{
printf("出栈失败!\n");
}
traverse(&S);//遍历输出
clear(&S);
traverse(&S);
return 0;
}
//初始化
void init(PSTACK pS){
pS->pTop=(PNODE)malloc(sizeof(NODE));
if(NULL==pS->pTop){
printf("动态内存分配失败!\n");
exit(-1);
}
else{
pS->pTop=pS->pBottom;
pS->pTop->pNext=NULL;
}
}
//压栈
void push(PSTACK pS,int val){
PNODE pNew=(PNODE)malloc(sizeof(NODE));//动态造出一个新的结点
pNew->data=val;
pNew->pNext=pS->pTop;
pS->pTop=pNew;
return;
}
//遍历输出
void traverse(PSTACK pS){
PNODE p=pS->pTop;
while(p!=pS->pBottom){
printf("%d\t",p->data);
p=p->pNext;
}
printf("\n");
return ;
}
//判断栈是否为空
bool empty(PSTACK pS){
if(pS->pTop=pS->pBottom){
return true;
}
else{
return false;
}
}
//出栈
void pop(PSTACK pS,int * pVal){
if(empty(pS)){
return false;
}
else{
PNODE r=pS->pTop;
*pVal=r->data;
pS->pTop=r->pNext;
free(r);
r=NULL;
return true;
}
}
//清空栈
void clear(PSTACK pS){
if(empty(pS)){
return ;
}
else{
PNODE p=pS->pTop;
PNODE q=NULL;
while(p!=pS->pBottom){
q=p->pNext;
free(p);
p=q;
}
pS->pTop=pS->pBottom;
}
}
//错误代码为 39 5 C:\Users\WP-S10\Desktop\练习\栈代码练习.c [Error] void value not ignored as it ought to be