c语言创建学生成绩表,C语言创建信息链表,求助
我想創(chuàng)建一個學(xué)生信息成績冊,程序如下,能輸入,但顯示不出來,怎么回事啊?求助
#include
#include
#define NULL 0
#define LEN sizeof(struc
我想創(chuàng)建一個學(xué)生信息成績冊,程序如下,能輸入,但顯示不出來,怎么回事啊?求助
#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);
}
展開
全部
總結(jié)
以上是生活随笔為你收集整理的c语言创建学生成绩表,C语言创建信息链表,求助的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ryzen处理器内存选择:频率、容量、时
- 下一篇: 内存升级,双通道加速