我实在的调不出来了,求帮忙!!!
一个关于学生成绩管理系统的代码,编译后总提示void exit(struct student *manage,int n);这一行有second formal parameter list longer than the first list的警告,还有.c(140) : error C2198: 'exit' : too few actual parameters的错误,最后就是删除学生信息的那一段代码求完善,我编不了,谢谢各位了,代码如下:#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<malloc.h>
#include<conio.h>
void menu(struct student *manage,int n);
void score(struct student *manage,int n); //函
void output(struct student *manage,int *n);
void input(struct student *manage,int n);
void write(struct student *manage,int n); //数
void read(struct student *manage,int n);
void find(struct student *manage,int n);
void logout(struct student *manage,int n); //声
void exit(struct student *manage,int n);
void modify(struct student *manage,int n);
void insert(struct student *manage,int *n); //明
struct student
{
int number; //学号
float score; //成绩
char name[10]; //姓名
};
int main()
{
struct student *manage;
int n=0;
char ch='\0';
printf("请输入存入的学生人数:");
scanf("%d",&n);
manage=(struct student *)malloc((sizeof(struct student)*n));
menu(manage,n);
printf("点回车继续\n");
while(1)
{
system("cls");
printf("\n\n\n\n\n");
printf("\t\t|******************************************|\n");
printf("\t\t|--------------- 学生管理系统 -------------|\n");
printf("\t\t|------------ 1.写入学生信息 ---------|\n");
printf("\t\t|------------ 2.查看全部学生信息 ---------|\n");
printf("\t\t|------------ 3.按成绩排序 ---------|\n");
printf("\t\t|------------ 4.按学号查找 ---------|\n");
printf("\t\t|------------ 5.修改学生信息 ---------|\n");
printf("\t\t|------------ 6.添加学生 ---------|\n");
printf("\t\t|------------ 7.保存 ---------|\n");
printf("\t\t|------------ 0.退出 ---------|\n");
printf("\t\t|******************************************|\n");
printf("\t\t\n");
scanf("%c",&ch);
switch(ch)
{
case'1':input(manage,n); break;
case'2':output(manage,&n); break;
case'3':score(manage,n); break;
case'4':find(manage,n); break;
case'5':modify(manage,n); break;
case'6':insert(manage,&n); break;
case'7':write(manage,n); break;
case'0':exit(manage,n); break;
default:printf("\n\t输入错误,点回车返回!");
getchar();
}
}
free(manage);
return 0;
}
//成绩排序
void score(struct student *manage,int n)
{
int i,j;
struct student t;
for(i=0;i<n-1;i++)
{
for(j=0;j<n;j++)
if(manage[j+1].score>manage[j].score)
{
t=manage[j+1];
manage[j+1]=manage[j];
manage[j]=t;
}
}
output(manage,&n);
return;
}
//函数功能:打印信息
void output(struct student *manage,int *n)
{
int i;
for(i=0;i<*n;i++)
printf("姓名:%s 成绩:%.2f 学号:%d\n",manage[i].name,manage[i].score,manage[i].number);
printf("\n");
getchar();
getchar();
return;
}
//函数功能:输入数据
void input(struct student *manage,int n)
{
int i;
for(i=0;i<n;i++)
{
printf("请输入第%d个学生的信息:",i+1);
printf("姓名:");
scanf("%s",manage[i].name);
printf("成绩:");
scanf("%f",&manage[i].score);
printf("学号:");
scanf("%d",&manage[i].number);
}
printf("\n");
return;
}
/*函数功能:将数据写入文件*/
void write(struct student *manage,int n)
{
int i;
FILE *fp = NULL;//定义文件指针
fp = fopen("E:\\student.txt","w");//打开文件并使文件指针指向它,以写的方式
if(fp == NULL)//如果文件没有打开,提示错误并退出
{
printf("\n\t文件没有打开!程序结束!");
getchar();
exit(0);//结束整个程序
}
else
{
for(i=0; i<n; i++)//将数据依次写入文件
{
fprintf(fp, "姓名:%s 成绩:%.2f 学号:%d\n",manage[i].name,manage[i].score,manage[i].number);
}
}
printf("已将学生信息保存在了E盘根目录下的student.txt文件中。\n");
getch();
fclose(fp);
return;
}
/*函数功能:读取文件数据*/
void read(struct student *manage,int n)
{
int i;
FILE *fp=NULL;
fp=fopen("E:\\student.txt","r");
if(fp==NULL)
{
printf("数据无法读取!\n");
getchar();
exit(0);
}
else
{
for(i=0;i<n;i++)
{
fscanf(fp,"%s,%d,%.2f\n",manage[i].name,manage[i].number,manage[i].score);
}
}
fclose(fp);
return;
}
/*函数功能:按学号找学生信息*/
void find(struct student *manage,int n)
{
int number=0;
int i;
printf("请输入学号:");
scanf("%d",&number);
for(i=0;i<n;i++)
{
if(number==manage[i].number)
{
printf("姓名:%s 成绩:%.2f 学号:%d\n",manage[i].name,manage[i].score,manage[i].number);
}
}
getchar();
return;
}
/*函数功能:删除学生信息*/
/*void logout(struct student *manage,int n)
{
char ch='\0';
find(manage,n);
printf("您确定要注销该学生吗?确定请按 Y,返回主菜单请按 N !\n");
scanf("%d",&ch);
if((ch=='Y')||(ch=='y'))
{
}
return;
}*/
void menu(struct student *manage,int n)
{
printf("\t\t||=========================================||\n");
printf("\t\t||-----------------------------------------||\n");
printf("\t\t||-----------欢迎使用学生管理系统----------||\n");
printf("\t\t||-----------------------------------------||\n");
printf("\t\t||=========================================||\n");
getchar();
getchar();
system("cls");
return;
}
/*函数功能:结束整个程序*/
void exit(struct student *manage,int n)
{
getchar();
char ch='\0';
do
{
char ch='\0';
printf("您确定要退出?(y/n):");
scanf("%c",&ch);
}
while((ch!='Y')&&(ch!='y')&&(ch!='N')&&(ch!='n'));
if((ch=='Y')||(ch=='y'))
{
exit(0);
}
return;
}
/*函数功能:修改学生信息*/
void modify(struct student *manage,int n)
{
int number=0;
char ch='\0';
int i;
printf("请您输入要修改的学生的学号:");
scanf("%d",&number);
for( i=0;i<n;i++)
{
if(number==manage[i].number)
{
printf("姓名:%s 成绩:%.2f 学号:%d\n",manage[i].name,manage[i].score,manage[i].number);
printf("您确定要修改该学生信息?(y/n");
scanf(" %c",&ch);
if(ch=='y')
{
printf("请输入姓名:");
scanf("%s",&manage[i].name);
printf("请输入成绩:");
scanf("%f",&manage[i].score);
printf("请输入学号:");
scanf("%d",&manage[i].number);
printf("姓名:%s 成绩:%.2f 学号:%d\n",manage[i].name,manage[i].score,manage[i].number);
printf("修改成功!");
getchar();
}
else
{
printf("查无此人!");
getchar();
break;
}
}
}
return;
}
/*函数功能:添加学生*/
void insert(struct student *manage,int *n)
{
int number=0;//添加学生的个数
int i;
printf("请输入您要添加几个学生信息:");
scanf("%d",&number);
manage=(struct student *)malloc((sizeof(struct student)*(*n+number)));
for(i=*n; i<*n+number;i++)
{
printf("请输入第%d个学生信息:",i+1);
printf("姓名:");
scanf("%s",manage[i].name);
printf("成绩: ");
scanf("%f",&manage[i].score);
printf("学号:");
scanf("%d",&manage[i].number);
}
output(manage,&*n);
}