c为什么报错
#include<stdio.h>
#include<stdlib.h>
struct List{
int a;
struct List *next;
};
void add(struct List **zhu)
{
struct List *b,*c;
b = (struct List *)malloc(sizeof(struct List));
if(b = NULL)
{
printf("内存分配失败\n");
exit(1);
}
printf("请输入数字:");
scanf("%d",&b->a);
if(*zhu != NULL)
{
c = *zhu;
*zhu = b;
b->next = c;
}
else
{
*zhu = b;
b->next = NULL;
}
}
int main()
{
struct List *zhu = NULL;
add(&zhu);
return 0;
} if(b = NULL) // 难道不应该是if(b == NULL) ?
{
printf("内存分配失败\n");
exit(1);
}
页:
[1]