【求助】结构体类型赋值提示类型不兼容
源代码:程序代码:
#include <stdlib.h> #include <stdio.h> #include <stdbool.h> #define OK 1 #define ERROR 0 typedef int SElementType; typedef int Status; typedef struct { SElementType data; struct StackNode *next; }StackNode,LinkStackPtr; typedef struct{ LinkStackPtr *top; int count; }LinkStack; void InitStack(LinkStack *S){ S->top = NULL; S->count = 0; } Status Push(LinkStack *S, SElementType e){ LinkStackPtr *s = (LinkStackPtr*)malloc(sizeof(StackNode)); if(s == NULL){ return ERROR; } s->data = e; s->next = S->top; S->top = s; S->count++; return OK; } bool StackEmpty(LinkStack *S){ if(S->count == 0){ return true; } return false; } Status Pop(LinkStack *S,SElementType *e){ LinkStackPtr *p; if(StackEmpty(S)){ return ERROR; } p = S->top; *e = p->data; S->top = p->next; S->count--; free(p); return OK; } int StackLength(LinkStack *S){ return S->count; } Status DestroyStack(LinkStack *S){ LinkStackPtr *p; while( (p = S->top) ){ S->top = p->next; free(p); } p = NULL; free(S); return OK; } int main(){ return 0; }
警告提示如下:
第30行提示指针类型不相同,同一个结构体的指针怎么会提示不相同呢?