一道c语言程序,请帮我看看错在哪

来源:百度知道 编辑:UC知道 时间:2024/06/27 12:23:16
写一个涵数要求,当输入e或E时记录学生资料,输入l或L打印已有的所记录,输入其他字符退出:
#include"stdio.h"
#include"stdlib.h"
struct stud
{char name[20];
long num;
int age;
char sex;
float score;
} student[30];
int n=0;
void redata();
void lst();
main()
{int flag=1;
char ch;
while(flag)
{printf("ntype'E'or'e'to enter new record,");
printf("ntype'L'or'l'to list all record;\n");
ch=getchar();getchar();
switch(ch)
{case'E':
case'e':redata();break;
case'L':
case'l':lst();break;
default :flag=0;}
}
}

void redata()
{char c[20];
printf("please enter the name:\n");
gets(student[n].name);
printf("please enter the num:\n");
gets(c);student[n].num=atol(c);
printf("please enter the age:\n");
gets(c);student[n].age=

#include"stdio.h"
#include"stdlib.h"
struct stud
{char name[20];
long num;
int age;
char sex;
float score;
} student[30];
int n=0;
void redata();
void lst();
main()
{int flag=1;
char ch;
while(flag)
{printf("ntype'E'or'e'to enter new record,");
printf("ntype'L'or'l'to list all record;\n");
ch=getchar();getchar();
switch(ch)
{case'E':
case'e':redata();break;
case'L':
case'l':lst();break;
default :flag=0;}
}
}

void redata()
{
char c[20];
printf("please enter the name:\n");
gets(student[n].name);
printf("please enter the num:\n");
gets(c);student[n].num=atol(c);
printf("please enter the age:\n");
gets(c);student[n].age=atoi(c);