c语言创建学生成绩表,C语言创建信息链表,求助

我想创建一个学生信息成绩册,程序如下,能输入,但显示不出来,怎么回事啊?求助

#include

#include

#define NULL 0

#define LEN sizeof(struc

我想创建一个学生信息成绩册,程序如下,能输入,但显示不出来,怎么回事啊?求助

#include

#include

#define NULL 0

#define LEN sizeof(struct student)

struct student

{

long stu_num;

char stu_name;

float stu_score;

struct student *next;

};

int n;

void main()

{

struct student *creat(void);

struct student *ty;

printf("\nPlease input the student information:");

printf("\nas the order of student number:\n");

ty=creat();

printf("\nNow,These records are:\n");

if(ty!=NULL)

do

{printf("%ld %s %5.1f\n",ty->stu_num,ty->stu_name,ty->stu_score);

ty=ty->next;

}while(ty!=NULL);

}

struct student *creat(void)

{

struct student *head;

struct student *t1,*t2;

n=0;

t1=t2=(struct student*)malloc(LEN);

scanf("%ld,%s,%f",&t1->stu_num,&t1->stu_name,&t1->stu_score);

head=NULL;

while(t1->stu_num!=0)

{

n=n+1;

if(n==1)head=t1;

else t2->next=t1;

t2=t1;

t1=(struct student*)malloc(LEN);

scanf("%ld,%s,%f",&t1->stu_num,&t1->stu_name,&t1->stu_score);

}

t2->next=NULL;

return(head);

}

展开

全部

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值