[求助]gets()与scanf()函数有冲突?
题目:链表的建立struct Addresslist *create()
{
struct Addresslist *head;
struct Addresslist *p;
struct Addresslist *tail;
char name[20];
head=NULL;
tail=NULL;
printf("输入第一个结点:\n");
printf("姓名:");
gets(name);
while(strcmp(name,"")!=0)
{
p=(struct Addresslist *)malloc(LEN);
if(p==NULL)
{
printf("内存不足!\n");
exit(1);
}
else
{
strcpy(p->name,name);
printf("输入分数:");
scanf("%s",p->score);
if(head==NULL)
head=p;
else
tail->next=p;
tail=p;
printf("输入下个个结点的数据:\n");
printf("姓名:");
gets(name);
}
}
if(head!=NULL)
tail->next=NULL;
printf("链表数据输入结束!\n");
return head;
}
程序跳过了红色那个gets(name)的语句,要是我把它改成scanf("%s",name)就可以读取scanf()这个语句,但是改了后是死
循环,红色的gets(name)不改,把scanf("%s",score)改成gets(score)循环一切就正常了?