代码异常结束是程序崩溃了吗?我这里测试把把Is_Empty()函数里的 if(s->next=NULL)改为 if(s->next==NULL)好像就可以了。判断是否等于是==,不是=。
#include <stdio.h>
#include <stdlib.h>
#define True 1
#define False -1
struct Stack_Node{
int data;
struct Stack_Node * next;
};
void Create_Stack(struct Stack_Node **p){
(*p) = (struct Stack_Node *)malloc(sizeof(struct Stack_Node));
(*p)->next =NULL;
}
int Is_Empty(struct Stack_Node *s){
if(s->next==NULL){
// printf("False\n");
return False;
}else{
// printf("NULL=%d,True\n",NULL);
return True;
}
}
int main(void){
int flag = 0;
struct Stack_Node SN;
struct Stack_Node * shead = NULL;
shead = &SN;
Create_Stack(&shead);
flag = Is_Empty(shead);
printf("%d",flag);
return 0;
}