[求助]结构体的问题 到底哪错了~~
应该录入三组数的,可是录入一组数就不让录入了?
# include<stdlib.h>
# define NULL 0
# define LEN sizeof(struct ren)
struct ren{
long num;
float fen;
struct ren *next;
};
int n;
struct ren *create(void)
{struct ren *p1,*p2,*head;
n=0;
p1=p2=(struct ren *)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->fen);
head=NULL;
while(p1->num!=0)
{
n=n+1;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct ren *)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->fen);
}
p2->next=NULL;
return(head);
}
void print(struct ren *head)
{struct ren *p;
p=head;
if(head!=NULL)
do
{
printf("%ld %5.1f\n",p->num,p->fen);
p=p->next;
}
while(p!=NULL);
}
main()
{ struct ren *head;
head=create();
print(head);
}
提示错误 scanf : floating point formats not linked
Abnormal program termination