一段VC代码,不知道怎么运行不了

来源:百度知道 编辑:UC知道 时间:2024/05/15 04:40:47
# include"stdio.h"
# define NULL 0
struct student
{
long num:
float score;
struct student *next;
};
void main()
{
struct student a,b,c,*head,*p;
a.num=10101;a.score=89.5;
b.num=10103;b.score=90;
c.num=10107;c.score=85;
head =&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do
{printf("%ld%5.1f\n",p->num,p->score);

p=p->next;
}while(p!=NULL);
}
总是提示没有定义变量,明明定义了啊

噢……

如果这代码是你直接从源文件考出来的话……问题我帮你找着了

你那个结构体里面确实有个错误:

long  num:

这个应该是个分号;你写个冒号了:错误就在这里……

改了就可以运行了: