大侠们再来解释下VC++6.0编译过不去的原因,该怎么处理
大侠们再来解释下VC++6.0编译过不去的原因
我这次是用VC++6.0创建的C程序
2个编译过不去上面有
d:\luanma\g.c(5) : warning C4005: 'NULL' : macro redefinition
d:\vc98\include\stdio.h(212) : see previous definition of 'NULL'
- C/C++ code
#include <stdio.h>
#include <stdlib.h>
typedef char type;
#define num 10
#define NULL 0
typedef struct node
{
type date;
struct node *right,*left;
}node;
typedef struct shed
{
node *p;
int top;
int size;
}shed;
int empty(shed *s)
{
if(s->top==0)
return 0;
return 1;
}
newshed(shed *s)/////////////////初始化栈
{
s->p=(node *)malloc(num*sizeof(node *));
s->top=0;
s->size=num;
}
int push(shed *s,node *p)//////////////////////压栈
{
if(s->top==s->size)
{
s->p=(node *)realloc(s->p,s->size*sizeof(node *));
if(!s->p)
return 0;
s->size++;
}
s->p[s->top]=p;///////////////这里错误
s->top++;
}
node *pop(shed *s)/////////////////弹栈
{
node *e;
if(s->top==0)
return 0;
e=s->p[s->top-1];
s->top--;
return e;
}
int gettop(shed *s)///////////////////////取栈顶元素
{
int e;
if(s->top==0)
return 0;
e=s->p[s->top-1].date;////////////////这里错误
return e;
}
node *buildtree()/////////////////树的建立
{
node *p;
type x;
scanf("%c",&x);
getchar();
if(x=='?')
p=NULL;
else
{
p=(node *)malloc(sizeof(node));
p->date=x;
p->left=buildtree();
p->right=buildtree();
}
return p;
}
int search(node *T,type x)/////////////////搜索
{
node *p=T,*q=NULL,*s=T;
int l=0,t;
while(p||!empty(s))
{
if(p!=q)
while(p)
{
push(s,p);
if(p->left)
p=p->left;
else p=p->right;
}
q=gettop(s);
if(q->date==x)
break;
if(q->right==p)
{
p=pop(s);
printf("%d",q->date);
}
else p=q->right;
}
while(!empyt(s))
{
t=pop(s);
l++;
}
return l;
}
main()
{
node *s;
shed p;
type t;
type z;
newshed(&p);
s=buildtree();
printf("input a No. to search\n");
scanf("%c",&t);
z=search(s,t);
}
我这次是用VC++6.0创建的C程序
2个编译过不去上面有
d:\luanma\g.c(5) : warning C4005: 'NULL' : macro redefinition
d:\vc98\include\stdio.h(212) : see previous definition of 'NULL'