下面是根据班级,这个人数较少的单位设计的学籍管理系统,录入时,要求班内序号由1开始  按顺序录入,其中主要用到了 结构体数组,文件处理,循环语句,选择语句等方面的知识
在设计中遇到一个问题就是  不知道怎样修改已经保存在文件中的某一个指定学生的信息,后来在询问学长之后才了解到  可以: 先把文件中的数据全部读入结构体数组中,再修改指定序号的数组元素,然后再用“wt”的方式写进原文件,这样就可以删除文件里的原内容,再写进新内容
下面是源代码,在Dev-C++ 条件下进行编译
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
int count1=0;
int count2=0;
int count3=0;
void class_print();
void men1_student();
void men2_student();
void men3_student();
void men4_student();
void input_student();
void input_grade();
void input_reward();
void input_finance();
void report_finance();
void seek_student();
void seek_grade();
void seek_reward();
void change_student();
void change_grade();
void change_reward();
int now1_student();
int now2_student();
int now3_student();
struct date
{int year;int month;int day;
};
struct student
{char number[2];char name[10];char sex[4];char tel[15];char id[20];char study[10];
};
struct grade
{char number[2];char name[10];char math[4];char English[4];char Cprogram[4];char sumtest[4];
};
struct reward
{char number[2];char name[10];struct date time;char rewarding[80];
};
struct finance
{char thing[20];char type[8];struct date time2;int i;
};
struct student m_stu[50];
struct grade g_stu[50];
struct reward r_stu[50];
struct finance f_class;
struct grade t_change;
main()
{int choice=-1;                                                 //一级菜单 while(choice!=0){printf("\n");printf("\t\t\t\t\t\t**");  class_print();  printf("**\n");    printf("\t\t\t\t\t\t****************************\n");printf("\t\t\t\t\t\t**  班级学生学籍管理系统  **\n");printf("\t\t\t\t\t\t**     1.户籍管理系统     **\n");printf("\t\t\t\t\t\t**     2.成绩管理系统     **\n");printf("\t\t\t\t\t\t**     3.奖惩管理系统     **\n");printf("\t\t\t\t\t\t**     4.财务管理系统     **\n");printf("\t\t\t\t\t\t**     0.退        出     **\n");printf("\t\t\t\t\t\t请选择");scanf("%d",&choice);switch(choice){ case 1:men1_student();break;case 2:men2_student(); break;case 3: men3_student();break;case 4: men4_student();break;case 0:printf("返回上一级");break; default :break;}}
}
void men1_student()                                                                              //二级菜单(学生户籍管理)
{
int choice=-1;
while(choice!=0){printf("\n");printf("\t\t\t\t\t\t****************************\n");printf("\t\t\t\t\t\t**");  class_print();  printf("**\n");printf("\t\t\t\t\t\t**  班级学生户籍信息管理  **\n");printf("\t\t\t\t\t\t**  户籍信息已录入人数:");now1_student();printf("  **\n");printf("\t\t\t\t\t\t**     1.户籍录入系统     **\n");printf("\t\t\t\t\t\t**     2.户籍修改系统     **\n");printf("\t\t\t\t\t\t**     3.户籍查询系统     **\n");printf("\t\t\t\t\t\t**     0.返        回     **\n");printf("\t\t\t\t\t\t请选择"); scanf("%d",&choice);  switch(choice){case 1:input_student();break;case 2:change_student();break;case 3:seek_student();break;case 0:printf("返回上一级");break;default :break;}getch();}
}void input_student()                                                                                   // 户籍录入函数  录入信息保存至D盘根目录下information1.txt文件下{int j;printf("学生户籍信息录入");printf("\n班内序号: ");scanf("%s",&m_stu[count1].number);printf("\n姓名: ");gets(m_stu[count1].name);gets(m_stu[count1].name);printf("\n性别: ");scanf("%s",&m_stu[count1].sex);printf("\n电话号码: ");scanf("%s",&m_stu[count1].tel);printf("\n身份证号: ");scanf("%s",&m_stu[count1].id);printf("\n学号: ");scanf("%s",&m_stu[count1].study);printf("是否保存该学生信息?1-保存 2-放弃");scanf("%d",&j);if(j==1){FILE *info;                                           //保存至本地文件 info=fopen("d:\\information1.txt","at+");fwrite(&m_stu[count1],sizeof(struct student),1,info);fclose(info);printf("信息已保存至D:\\information1.tex 文件下,按任意键继续");count1++;}else printf("放弃保存,按任意键继续"); }
void seek_student()                                                                               //查询户籍信息函数                  {FILE *info;                                       info=fopen("d:\\information1.txt","rt");int i;printf("请输入该学生班内序号");scanf("%d",&i);if(i<1||i>50) printf("抱歉,该学生信息不存在");else {rewind(info);fseek(info,sizeof(struct student)*(i-1),0);fread(&m_stu[i-1],sizeof(struct student),1,info);printf("\n\n序号 姓名    性别 电话号码\t   身份证号\t\t学号\t");printf("\n\n%d   %s   %s   %s   %s    %s",i,m_stu[i-1].name,m_stu[i-1].sex,m_stu[i-1].tel,m_stu[i-1].id,m_stu[i-1].study);}}void change_student()                                                                           //修改户籍信息{int i=0,j,k,f;char h[100000];FILE *info; info=fopen("d:\\information1.txt","rt");printf("\n\t请输入要修改户籍信息的学生班内序号");scanf("%d",&j);if(j<1||j>50) printf("抱歉,该学生信息不存在");else {rewind(info);while(fgets(h,sizeof(struct student),info)!=NULL){fseek(info,sizeof(struct student)*i,0);fread(&m_stu[i],sizeof(struct student),1,info);i++;}}fclose(info);printf("\n该学生目前户籍信息为\n:");printf("\n\n序号 姓名    性别 电话号码\t   身份证号\t\t学号\t");printf("\n\n%d   %s   %s   %s   %s    %s",j,m_stu[j-1].name,m_stu[j-1].sex,m_stu[j-1].tel,m_stu[j-1].id,m_stu[j-1].study);printf("确定修改此学生信息?1- 修改 2- 返回");scanf("%d",&k);if(k==1){printf("\n姓名: ");gets(m_stu[j-1].name);gets(m_stu[j-1].name);printf("\n性别: ");scanf("%s",&m_stu[j-1].sex);printf("\n电话号码: ");scanf("%s",&m_stu[j-1].tel);printf("\n身份证号: ");scanf("%s",&m_stu[j-1].id);printf("\n学号: ");scanf("%s",&m_stu[j-1].study);} else return;                                     info=fopen("d:\\information1.txt","wt");for(f=0;f<i;f++){fseek(info,sizeof(struct student)*f,0);fwrite(&m_stu[f],sizeof(struct student),1,info);}fclose(info);printf("修改成功!");}void men2_student()                                                                           //二级菜单(学生成绩管理){int choice=-1; while(choice!=0){printf("\n\t\t\t\t\t\t****************************\n");printf("\t\t\t\t\t\t**");  class_print();  printf("**\n");printf("\t\t\t\t\t\t**  班级学生成绩信息管理  **\n");printf("\t\t\t\t\t\t**  成绩信息已录入人数:");now2_student();printf("  **\n");printf("\t\t\t\t\t\t**     1.成绩录入系统     **\n");printf("\t\t\t\t\t\t**     2.成绩修改系统     **\n");printf("\t\t\t\t\t\t**     3.成绩查询系统     **\n");printf("\t\t\t\t\t\t**     4.综测排名系统     **\n");printf("\t\t\t\t\t\t**     0.返        回     **\n");printf("\t\t\t\t\t\t请选择"); scanf("%d",&choice); switch(choice){case 1:input_grade(); break;case 2:change_grade();break;case 3:seek_grade();break;case 4:printf("功能正在研发中,敬请期待..."); break;default:break;}getch();} }
void input_grade()                                                                                          // 成绩录入函数   ,录入信息保存至 D盘根目录下information2.txt文件下{int j;printf("学生成绩信息录入");printf("\n班内序号");scanf("%s",&g_stu[count2].number);printf("\n姓名: ");gets(g_stu[count2].name);gets(g_stu[count2].name);printf("\n高数: ");scanf("%s",&g_stu[count2].math);printf("\n英语:");scanf("%s",&g_stu[count2].English);printf("\nC语言:");scanf("%s",&g_stu[count2].Cprogram);printf("\n综测:");scanf("%s",&g_stu[count2].sumtest);printf("是否保存该学生信息?1-保存 2-放弃");scanf("%d",&j);if(j==1){FILE *info2;                                           //保存至本地文件 info2=fopen("d:\\information2.txt","at+");fwrite(&g_stu[count2],sizeof(struct grade),1,info2);fclose(info2);printf("信息已保存至D:\\information.tex2 文件下,按任意键继续");count2++;}else printf("放弃保存,按任意键继续"); }void seek_grade()                                                                                      //查询成绩信息函数                  {FILE *info2;                                       info2=fopen("d:\\information2.txt","rt");int i;printf("\n\t请输入该学生班内序号");scanf("%d",&i);if(i<1||i>50) printf("\n抱歉,该学生信息不存在");else {rewind(info2);fseek(info2,sizeof(struct grade)*(i-1),0);fread(&g_stu[i-1],sizeof(struct grade),1,info2);printf("\n\n序号 姓名  高数  英语  C语言  综测");printf("\n\n%d   %s   %s   %s   %s    %s",i,g_stu[i-1].name,g_stu[i-1].math,g_stu[i-1].English,g_stu[i-1].Cprogram,g_stu[i-1].sumtest);}}
void change_grade()                                                                                     //修改成绩信息   {int i=0,j,k,f;char h[100000];FILE *info; info=fopen("d:\\information2.txt","rt");printf("\n\t请输入要修改成绩信息的学生班内序号");scanf("%d",&j);if(j<1||j>50) printf("\n抱歉,该学生信息不存在");else {rewind(info);while(fgets(h,sizeof(struct grade),info)!=NULL){fseek(info,sizeof(struct grade)*i,0);fread(&g_stu[i],sizeof(struct grade),1,info);i++;}}fclose(info);printf("\n该学生目前成绩信息为\n:");printf("\n\n序号 姓名  高数 英语  C语言  综测");printf("\n\n%d   %s   %s   %s   %s    %s",j,g_stu[j-1].name,g_stu[j-1].math,g_stu[j-1].English,g_stu[j-1].Cprogram,g_stu[j-1].sumtest);printf("\n\t确定修改此学生信息?1- 修改 2- 返回");scanf("%d",&k);if(k==1){printf("\n姓名: ");gets(g_stu[j-1].name);gets(g_stu[j-1].name);printf("\n高数: ");scanf("%s",&g_stu[j-1].math);printf("\n英语: ");scanf("%s",&g_stu[j-1].English);printf("\nC语言: ");scanf("%s",&g_stu[j-1].Cprogram);printf("\n综测: ");scanf("%s",&g_stu[j-1].sumtest);} else return;                                     info=fopen("d:\\information2.txt","wt");if(info==NULL){printf("不能打开此文件,按任意键继续");getch();}for(f=0;f<i;f++){fseek(info,sizeof(struct grade)*f,0);fwrite(&g_stu[f],sizeof(struct grade),1,info);}fclose(info);printf("修改成功!");}
void men3_student()                                                                           //二级菜单(学生奖惩管理)
{
int choice=-1;
while(choice!=0){printf("\n");printf("\t\t\t\t\t\t****************************\n");printf("\t\t\t\t\t\t**");  class_print();  printf("**\n");printf("\t\t\t\t\t\t**  班级学生奖惩信息管理  **\n");printf("\t\t\t\t\t\t**  奖惩信息已录入人数:");now3_student();printf("  **\n");printf("\t\t\t\t\t\t**     1.奖惩录入系统     **\n");printf("\t\t\t\t\t\t**     2.奖惩修改系统     **\n");printf("\t\t\t\t\t\t**     3.奖惩查询系统     **\n");printf("\t\t\t\t\t\t**     0.返        回     **\n");printf("\t\t\t\t请选择"); scanf("%d",&choice);  switch(choice){case 1:input_reward();break;case 2:change_reward();break;case 3:seek_reward();break;case 0:printf("返回上一级");break;default :break;}getch();}
}
void input_reward()                                                                                // 奖惩录入函数      录入信息保存至D盘根目录下information3.txt文件下{int j;printf("学生奖惩信息录入");printf("\n班内序号: ");scanf("%s",&r_stu[count3].number);printf("\n姓名: ");gets(r_stu[count3].name);gets(r_stu[count3].name);printf("\n奖惩时间: ");scanf("%d.%d.%d",&r_stu[count3].time.year,&r_stu[count3].time.month,&r_stu[count3].time.day);printf("\n具体事件: ");gets(r_stu[count3].rewarding);gets(r_stu[count3].rewarding);printf("\n是否保存该学生信息?1-保存 2-放弃");scanf("%d",&j);if(j==1){FILE *info;                                           //保存至本地文件 info=fopen("d:\\information3.txt","at+");fwrite(&r_stu[count3],sizeof(struct reward),1,info);fclose(info);printf("\n信息已保存至D:\\information3.tex 文件下,按任意键继续");count3++;}else printf("放弃保存,按任意键继续"); }
void seek_reward()                                                                                //查询奖惩信息函数     根据学生班级序号              {FILE *info;                                       info=fopen("d:\\information3.txt","rt");int i;printf("\n\t请输入该学生班内序号");scanf("%d",&i);if(i<1||i>50) printf("\n抱歉,该学生信息不存在");else {rewind(info);fseek(info,sizeof(struct reward)*(i-1),0);fread(&r_stu[i-1],sizeof(struct reward),1,info);printf("\n\n序号  姓名    奖惩时间                 具体事件\t\t");printf("\n\n%d   %s   %d.%d.%d   %s   ",i,r_stu[i-1].name,r_stu[i-1].time.year,r_stu[i-1].time.month,r_stu[i-1].time.day,    r_stu[i-1].rewarding);}}
void change_reward()                                                                            //修改奖惩信息{int i=0,j,k,f;char h[100000];FILE *info; info=fopen("d:\\information3.txt","rt");printf("\n\t请输入要修改奖惩信息的学生班内序号");scanf("%d",&j);if(j<1||j>50) printf("\n抱歉,该学生信息不存在");else {rewind(info);while(fgets(h,sizeof(struct reward),info)!=NULL){fseek(info,sizeof(struct reward)*i,0);fread(&r_stu[i],sizeof(struct reward),1,info);i++;}}fclose(info);printf("\n该学生目前奖惩信息为\n:");printf("\n\n序号 姓名  奖惩时间    具体事件");printf("\n\n%d   %s   %d.%d.%d   %s   ",j,r_stu[j-1].name,r_stu[j-1].time.year,r_stu[j-1].time.month,r_stu[j-1].time.day  ,r_stu[j-1].rewarding);printf("\n\t确定修改此学生信息?1- 修改 2- 返回");scanf("%d",&k);if(k==1){printf("\n姓名: ");gets(r_stu[j-1].name);gets(r_stu[j-1].name);printf("\n奖惩时间: ");scanf("%d.%d.%d",&r_stu[j-1].time.year,&r_stu[j-1].time.month,&r_stu[j-1].time.day);printf("\n具体事件: ");scanf("%s",&r_stu[j-1].rewarding);} else return;                                     info=fopen("d:\\information3.txt","wt");for(f=0;f<i;f++){fseek(info,sizeof(struct reward)*f,0);fwrite(&r_stu[f],sizeof(struct reward),1,info);}fclose(info);printf("修改成功!");}
int now1_student()                                                                    //录入户籍信息学生数目       在菜单中 显示 已经录入学生人数
{int i=1;char j[100000];FILE *info;info=fopen("D:\\information1.txt","rt");rewind(info);while(fgets(j,sizeof(struct student),info)!=NULL){fseek(info,sizeof(struct student)*i,0);i++;}fclose(info);printf("%d",i-1);
}int now2_student()                                                                     //录入成绩信息学生数目     在菜单中 显示 已经录入学生人数
{int i=1;char j[100000];FILE *info;info=fopen("D:\\information2.txt","rt");rewind(info);while(fgets(j,sizeof(struct grade),info)!=NULL){fseek(info,sizeof(struct grade)*i,0);i++;}fclose(info);printf("%d",i-1);
}int now3_student()                                                                       //录入奖惩信息学生数目     在菜单中 显示 已经录入学生人数
{int i=1;char j[100000];FILE *info;info=fopen("D:\\information3.txt","rt");rewind(info);while(fgets(j,sizeof(struct reward),info)!=NULL){fseek(info,sizeof(struct reward)*i,0);i++;}fclose(info);printf("%d",i-1);
}
void class_print()                                                                         // 录入专业班级信息,并保存至D盘根目录下information0.txt文件下
{char major[20],class_number[4];FILE *info;info=fopen("d:\\information0.txt","rt");if(info==NULL){info=fopen("d:\\information0.txt","wt");printf("\n请输入专业 :");scanf("%s",&major);printf("\n请输入班级 :");scanf("%s",&class_number);fwrite(major,sizeof(major),1,info);fwrite(class_number,sizeof(class_number),1,info);printf("\n\t已保存专业班级信息!");fclose(info);info=fopen("d:\\information0.txt","rt");fread(&major,sizeof(major),1,info);fread(&class_number,sizeof(class_number),1,info);printf("%s",major);printf("%s班",class_number); }else {fread(&major,sizeof(major),1,info);fread(&class_number,sizeof(class_number),1,info);printf("%s",major);printf("%s班",class_number);fclose(info);}
}
void men4_student()                                                                               //二级菜单(班级财务管理)
{
int choice=-1;
while(choice!=0){printf("\n");printf("\t\t\t\t\t\t****************************\n");printf("\t\t\t\t\t********财务信息不可修改,请谨慎录入!******\n");printf("\t\t\t\t\t\t**  班级学生财务信息管理  **\n");printf("\t\t\t\t\t\t**     1.财务录入系统    **\n");printf("\t\t\t\t\t\t**     2.财务报表系统    **\n");printf("\t\t\t\t\t\t**     0.返        回     **\n");printf("\t\t\t\t\t\t请选择"); scanf("%d",&choice);  switch(choice){case 1:input_finance();break;case 2:report_finance(); break;case 3:case 0:printf("返回上一级");break;default :break;}getch();}
}void input_finance()                                                                        // 财务录入函数 ,录入后信息保存到D盘根目录下 information4.txt文件中{int j;printf("班级财务信息录入");printf("\n收支时间: ");scanf("%d.%d.%d",&f_class.time2.year,&f_class.time2.month,&f_class.time2.day );printf("\n具体事件: ");gets(f_class.thing);gets(f_class.thing);printf("\n财务类型(收入或开支): ");scanf("%s",&f_class.type);printf("\n流动金额(收入为正开支为负): ");scanf("%d",&f_class.i);printf("\n是否保存该财务信息?1-保存 2-放弃");scanf("%d",&j);if(j==1){FILE *info;                                           //保存至本地文件 info=fopen("d:\\information4.txt","at+");fwrite(&f_class,sizeof(struct finance),1,info);fclose(info);printf("\n信息已保存至D:\\information4.txt 文件下,按任意键继续");}else printf("放弃保存,按任意键继续"); }
void report_finance()                                                                                       // 财务信息报表
{    char h[100000];int sum=0,i=0;printf("\n收支时间   具体事件\t财务类型  流动金额\n");FILE *info;                                       info=fopen("d:\\information4.txt","rt");while(fgets(h,sizeof(struct finance),info)!=NULL){fseek(info,sizeof(struct finance)*i,0);fread(&f_class,sizeof(struct finance),1,info);i++;printf("\n%d.%d.%d %s          %s           %d\n",f_class.time2.year,f_class.time2.month,f_class.time2.day,  f_class.thing,f_class.type,f_class.i);sum=sum+f_class.i ;}printf("\n\t\t班费余额:%d元",sum);
}

C语言—班级学生管理系统相关推荐

  1. c语言程序设计班档案管理系统报告,C语言班级档案管理系统

    <C语言班级档案管理系统>由会员分享,可在线阅读,更多相关<C语言班级档案管理系统(28页珍藏版)>请在人人文库网上搜索. 1.c语言程序设计"课程设计报告班级档案管 ...

  2. c语言课程班级档案管理系统,C语言班级档案管理系统

    <C语言班级档案管理系统>由会员分享,可在线阅读,更多相关<C语言班级档案管理系统(23页珍藏版)>请在人人文库网上搜索. 1.精品文档课程设计任务书课程名称 C语言课程设计 ...

  3. C/C++语言实现 学生管理系统

    C/C++语言实现 学生管理系统 首先,让我分部分介绍本学生管理系统 本系统分为两个大板块,分别是学生版和教师版,学生版又分出三个具体功能,教师版分为七个功能,让我依次来介绍它们吧! (一)学生版 1 ...

  4. C语言实现学生管理系统

    C语言实现-学生管理系统 程序员的必经之路吧,学生管理系统.在制作过程中体会到了编写一个具体可用的软件而要做的工作,无论是编写前的准备,还是编写过程中每个细节的处理,都让我理解了这份工作是个什么样子. ...

  5. 学生管理系统c#语言代码,基于C#语言的学生管理系统的设计(ASP.NET2.0)

    摘  要 随着科学技术的不断提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用.学生管理系统是学校管理中不可少的一部分.而基于B/S架构的学生管 ...

  6. c语言程序设计课题为车票管理系统,c语言 班级成管理系统.doc

    课 程 设 计 报 告 课程名称 C语言程序设计 课题名称 班级成绩管理系统 专 业 网络工程 班 级 1001 学 号 201003120129 姓 名 张剑 指导教师 唐北平.陈淑红.谭小兰 20 ...

  7. 语言学生学籍管理系统流程图_基于C语言的学生管理系统(含文件)(一)

    "点击上方"蓝色字",关注我们哦(*^▽^*)!" NO.1 篇幅较长,请空闲时观看 前言 这个项目是大一暑假完成,纯C语言编写,界面比较美观,由于当时还是一个 ...

  8. C语言班级财务管理系统

    一.需求分析 1.系统概述: 班级财务管理是班级日常生活必不可少的,反应了班级财务的运作功能与过程,采用计算机来管理班级财务管理系统可方便快捷地查询与管理.本系统是班级财务管理系统,可让使用者明白地记 ...

  9. (C语言)学生管理系统

    学生管理系统 题目:编写学生管理系统,其中学生的信息有姓名(汉语拼音,最多20个字符),性别(男/女,用1表示男,2表示女). 生日(19850101(年月日)).身高(以m为单位),还需要处理C语言 ...

最新文章

  1. python项目-30 个惊艳的Python开源项目
  2. 16 分频 32 分频是啥意思_Verilog 数字分频器的设计及验证
  3. 北邮OJ 980. 16校赛-R_clover's Challenge
  4. 《大型网站技术架构》读书笔记之八:固若金汤之网站的安全性架构
  5. 分区和分片的区别_MySQL分区与分片的差异
  6. 让 .Net 更方便的导入导出Excel
  7. CSS 学习路线(二)选择器
  8. typescript的类型描述_TypeScript类型声明书写详解
  9. My new English
  10. HDU3789 奥运排序问题【序列处理】
  11. 第十章 嵌入式linux的调试技术
  12. 世界主要国家地区英文名称,缩写代码
  13. [奇异吸引子]相关知识点
  14. 学习方法论与相关建议
  15. 属性动画cancel
  16. 守护安全|AIRIOT城市天然气综合管理解决方案
  17. 【亲测有效】树莓派4B安装realsense(Intel深度摄像头)
  18. 【Android】【UI】ACTION_CANCEL什么时候执行
  19. Excel学习——制作周报
  20. 游戏低延迟高续航真无线蓝牙耳机,小巧便捷出差旅行必备

热门文章

  1. Excel中序号自动填充
  2. 传奇SF的架设-开外网
  3. 人才补贴,正式取消?
  4. Linux 5.19 迎来首个候选版本,Linus:多平台 Linux 内核“差不多完成了”
  5. <金屋藏书>app 技术支持
  6. 最最基本的SQL手动url注入方法
  7. VS2019c++配置GDAL和HDF库新手入门
  8. get_price函数定义python_python get()函数
  9. 最近经常看到网上程序员被抓,如何避免面向监狱编程!?
  10. 蓝牙耳机选哪种的比较好、高端蓝牙耳机推荐