求助,C语言结构体数组的赋值

#include<stdio.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#define N 34
struct student
{ int ID;
char name;
int mscore;//数学成绩
int escore;//英语成绩
int cscore;//语文成绩
};
struct student stu[34];

void Input(stu);
char search(int a,char b);

/*float time ()
{
time_t t;
struct tm * lt;
time (&t);//获取Unix时间戳。
lt = localtime (&t);//转为时间结构。
printf ( "%d/%d/%d %d:%d:%d\n",lt->tm_year+1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);//输出结果

}
*/

/*
void main()
{ int select;
FILE *fp;
printf("1.学生成绩录入:\n");
printf("2.所有学生成绩显示:\n");
printf("3.学生信息查询:\n");
printf("4.学生信息增添\n");
printf("5.学生信息删除\n");
printf("6.学生信息统计\n");
printf("请输入要执行的操作:");

scanf("%d",select);
switch(select)
{case 1:Input(stu);// f(1)实现对N名学生成绩的录入并储存
case 2:fp=fopen("static.txt","r");break; //显示所有学生成绩
case 3:search(int id,char nam);break; //通过学号或姓名查询
case 4:f(4);break; //添加信息
case 5:f(5);break; //删除
case 6:f(6);break; //统计不及格学生人数和名单,统计各个分数段人数及比例
}
}
*/

void INPUT(stu)
{ int n,i;
float num,score1,score2,score3;
char name;
printf("input the number of students:");
scanf("%d",&n);
for(i=0;i<n+1;i++)
{
printf("please input the ID:");
scanf("%d",num);
stu[i].ID=num;
printf(" input the name:");
getchar();
stu[i].name=getchar();
printf("please input the maths score:");
scanf("%f",&score1);
stu[i].mscore=score1;
printf("please input the English score:");
scanf("%f",&score2);
stu[i].escore=score2;

printf("please input the Chinese score:");
scanf("%f",&score3);
stu[i].cscore=score3;
}
FILE *fp;
fp=fopen("static.txt","w+");
for(i=0;i<34;i++)
fputs(stu[i],fp);

}

到底是哪错了,求助

#include<stdio.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>

#define N 34

struct student {
int ID;
char name;
int mscore;//数学成绩
int escore;//英语成绩
int cscore;//语文成绩
}stu[N];

void Input(struct student stu,int n);
char search(int a,char b);

/*float time ()
{
time_t t;
struct tm * lt;
time (&t);//获取Unix时间戳。
lt = localtime (&t);//转为时间结构。
printf ( "%d/%d/%d %d:%d:%d\n",lt->tm_year+1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);//输出结果

}
*/

/*
void main()
{ int select;
FILE *fp;
printf("1.学生成绩录入:\n");
printf("2.所有学生成绩显示:\n");
printf("3.学生信息查询:\n");
printf("4.学生信息增添\n");
printf("5.学生信息删除\n");
printf("6.学生信息统计\n");
printf("请输入要执行的操作:");

scanf("%d",select);
switch(select)
{case 1:Input(stu);// f(1)实现对N名学生成绩的录入并储存 
case 2:fp=fopen("static.txt","r");break; //显示所有学生成绩 
case 3:search(int id,char nam);break; //通过学号或姓名查询 
case 4:f(4);break; //添加信息 
case 5:f(5);break; //删除 
case 6:f(6);break; //统计不及格学生人数和名单,统计各个分数段人数及比例
}
}
*/

void INPUT() {
FILE *fp;
fp = fopen("static.txt","wt");
for(i = 0; i < N; i++) {
printf("please input the ID name and grades:");
scanf("%d %s %f %f %f",&stu[i].ID,stu[i].name,&stu[i].mscore,&stu[i].escore,&stu[i].cscore);
fprintf(fp,"%d %s %f %f %f\n",stu[i].ID,stu[i].name,stu[i].mscore,stu[i].escore,stu[i].cscore);
}
fclose(fp);
}
温馨提示:答案为网友推荐,仅供参考
相似回答