|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这个异常怎么办
#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);
- }
复制代码
|
|