建立静态链表,接收不到用户输入的第一组数据


#include<stdio.h>

void input();
void print();

struct student{
    int number;
    int score;
    struct student *next;
}stu1,stu2,stu3;

int i;

int main()
{
    struct student *head;
    head=&stu1;
    stu1.next=&stu2;
    stu2.next=&stu3;
    stu3.next=NULL;
    struct student *n;
    n=head;
    input(*n);
    print(*n);
    return 0;
}

void input(struct student *a)
{
    printf("Please enter the information of students:\n");
    for(i=0;i<3;i++){
        scanf("%d %d",&(*a).number,&(*a).score);
        a=(*a).next;
    }
}

void print(struct student *p)
{
    printf("\nThe information of them is:\n");
    for(i=0;i<3;i++){
        printf("%d %d\n",(*p).number,(*p).score);
        p=(*p).next;
    }
}

为什么stu1接收不到输入的第一组数据?打印结果第一组数据为0 0,另外两组的数据都正常。

供参考:

#include<stdio.h>
void input();
void print();
struct student{
    int number;
    int score;
    struct student *next;
}stu1,stu2,stu3;
int i;
void input(struct student *a); //修改
void print(struct student *p); //修改
int main()
{
    struct student *head;
    head=&stu1;
    stu1.next=&stu2;
    stu2.next=&stu3;
    stu3.next=NULL;
    struct student *n;
    n=head;
    input(n);//input(*n); 修改
    print(n);//print(*n);
    system("pause");
    return 0;
}
void input(struct student *a)
{
    printf("Please enter the information of students:\n");
    for(i=0;i<3;i++){
        scanf("%d %d",&(*a).number,&(*a).score);
        a=(*a).next;
    }
}
void print(struct student *p)
{
    printf("\nThe information of them is:\n");
    for(i=0;i<3;i++){
        printf("%d %d\n",(*p).number,(*p).score);
        p=(*p).next;
    }
}