关于学生管理系统的,帮忙看看,本人菜鸟一个
# include <stdio.h>
# include <stdlib.h>
# include "ctype.h"
# include "conio.h"
# include "io.h"
# include "windows.h"
# include "ctype.h"
# include "string.h"
# define N 50
static n=0;
struct stuinfo{//定义结构体
char name[20];
long num;
char sex;
float scor;
}stu[N],*student;
void goxy(int x,int y)//光标定位
{
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD seps;
seps.X=x;
seps.Y=y;
SetConsoleCursorPosition(hcon,seps);
}
void frame(int x,int y,int wideth,int higth)//边框函数
{
for(int i=0;i<higth;i++)
for(int j=0;j<wideth*2;j+=2)
{
goxy(x+j,y+i);
if(j==0||j==wideth*2-2||i==0||i==higth-1){
if(i==0&&j==0)
printf("┏");
else if(i==0&&j==wideth*2-2)
printf("┓");
else if(i==higth-1&&j==0)
printf("┗");
else if(i==higth-1&&j==wideth*2-2)
printf("┛");
else if(i==0||i==higth-1)
printf("━");
else
printf("┃");
}
}
}
void menus()//菜单函数
{
system("cls");
goxy(30,5);
puts("学生信息管理系统");
puts("\t\t\t---------------------------");
puts("\t\t\t\t功 能 菜 单");
puts("\t\t\t---------------------------");
puts("\t\t 1. 输入学生数据\t 2.查看学生数据");
frame(10,3,30,18);
}
void newdata()//建立一个学生信息
{
system("cls");
printf("please input the %d strdents's datas(name,num,sex,scor)\n",n+1);
printf("input name:");
scanf("%s",stu[n].name);
getchar();
printf("input number:");
scanf("%ld",&stu[n].num);
getchar();
printf("input sex:");
scanf("%c",&stu[n].sex);
getchar();
printf("input score:");
scanf("%f",&stu[n].scor);
getchar();
n++;
}
void savemessage()//输入学生的信息,并保存到文件
{
do{
FILE *fp;
fp=fopen("message.txt","at+");
if(fp==NULL){
printf("打开文件失败");
exit(0);
}
newdata();
fwrite(&stu[n],sizeof(stu[n]),1,fp);
puts("\n\t\t按任意键继续,@键结束输入");
}while(getch()!='@');
}
void output(struct stuinfo *s)//输出
{
printf("%-12s\t %-8ld\t %c\t %6.2f\n",s->name,s->num,s->sex,s->scor);
}
void list()//列出学生信息
{
FILE *fp;
fp=fopen("message.txt","rb");
for(int i=0;i<n;i++)
{
fread(&stu[n],sizeof(*student),1,fp);
printf("%-12s\t %-8ld\t %c\t %6.2f\n",stu[n].name,stu[n].num,stu[n].sex,stu[n].scor);
}
}
void choic()
{
menus();
char c;
goxy(25,18);
printf("请输入你的选择(1~2):");
c=getchar();
switch(c)
{
case '1':
savemessage();
menus();
break;
case '2':
list();
menus();
break;
default:;
}
}
void main()//主函数
{
system("cls");
printf("\n\n\n%25c欢迎使用学生信息管理系统",32);
Sleep(500);
system("cls");
choic();
}
运行部了,编译没错 望不妥之处 多多指教