为什么用尾插法建立链表会无法输入数据?
#include<stdio.h>#include<stdlib.h>
typedef struct player
{
int value;
struct player *next;
}PLAYER;
int main()
{
int number=0,i=0;
PLAYER *head=NULL;
PLAYER *p=head;
do
{
scanf("%d",&number);
if(number!=-1)
{
i++;
PLAYER *q=(PLAYER *)malloc(sizeof(PLAYER));
q->value=number;
q->next=NULL;
p->next=q;
p=q;
}
}
while(number!=-1);
}