简单的链表问题 哎 还是不行啊 大家一起来帮帮忙啊 3q了
运行的时候一直是输入 没有输出#include <stdio.h>
#include <malloc.h>
#define NULL 0 //这里出现了redefined
#define LEN sizeof(struct student)
struct student
{
long num;
char name[20];
char sex[6];
float score[3];
struct student*next;
};
int main ()
{
int n=1;
struct student *head,*p1,*p2;
head=p1=p2=(struct student*)malloc(LEN);
scanf("%d %s %s %f %f %f",&p1->num,
p1->name,
p1->sex,
&p1->score[0],
&p1->score[1],
&p1->score[2]);//format '%d' expects type 'int *', but argument 2 has type 'long int *'
while(p1->num!=0)
{
if(n>1)
p2->next=p1;
p2=p1;
n++;
p1=(struct student*)malloc(LEN);
scanf("%d %s %s %f %f %f",&p1->num,
p1->name,
p1->sex,
&p1->score[0],
&p1->score[1],
&p1->score[2]);// &p1->score[2]这句出现了format '%d' expects type 'int *', but argument 2 has type 'long int *'
}
p1=NULL;
p1=head;
if(p1!=NULL)
do
{
printf("%d %s %s %f %f %f",&p1->num,
p1->name,
p1->sex,
&p1->score[0],
&p1->score[1],
&p1->score[2]);//format '%d' expects type 'int *', but argument 2 has type 'long int *'
p1=p1->next;
}while(p1!=NULL);
return 0;
}