#include<stdio.h>
struct student{
long num;
float score;
struct student *next;
};
void main()
{
struct student stu1,stu2,stu3,*p,*head;
stu1.num=10101; stu1.score=97;
stu2.num=10102; stu2.score=99;
stu3.num=10103; stu3.score=95.5;
head=&stu1;
stu1.next=&stu2;
stu2.next=&stu3;
stu3.next=NULL;
p=head;
do {
printf("%ld%5.1f\n",p->num,p->score);
p=p->next;
}while(p=!NULL);
}
运行出现“warning: assignment makes pointer from integer without a cast”错误
运行结果:
1001 97.0
段错误
无法得到后面几个结果
struct student{
long num;
float score;
struct student *next;
};
void main()
{
struct student stu1,stu2,stu3,*p,*head;
stu1.num=10101; stu1.score=97;
stu2.num=10102; stu2.score=99;
stu3.num=10103; stu3.score=95.5;
head=&stu1;
stu1.next=&stu2;
stu2.next=&stu3;
stu3.next=NULL;
p=head;
do {
printf("%ld%5.1f\n",p->num,p->score);
p=p->next;
}while(p=!NULL);
}
运行出现“warning: assignment makes pointer from integer without a cast”错误
运行结果:
1001 97.0
段错误
无法得到后面几个结果