C语言学生信息管理系统设计 C语言学生信息管理系统设计学生信息管理系统设计 学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:
1、系统以菜单方式工作
2、学生信息录入功能(学生信息用文件保存)
3、学生信息浏览功能
4、学生信息查询功能
按学号查询
按姓名查询5.学生信息的删除与修改(可选项)
SIMS.h#ifndef?_SIMS_H_
#define?_SIMS_H_struct?StudentMessageS
{
?//学号,姓名,年龄,性别,出生年月,地址,电话,E?-?mail等。
?char?StudentID[20];
?char?StudentName[30];
?char?StudentAge[10];
?char?StudentSex[10];
?char?StudentDate[30];
?char?StudentAddr[512];
?char?StudentPhone[20];
?char?StucentEmail[30];
};
int?StudentMessageLogin();???//学生信息录入
int?StudentMessageSee();???//学生信息浏览
int?StudentMessageQueryByNum();??//学生信息查询-按学号
int?StudentMessageQueryByName();?//学生信息查询-按姓名
int?DeleteStudentMessage();???//删除学生信息
int?UpdateStudentMessage();???//修改学生信息#endif?SIMS.cpp#include?
#include?
#include?
#include?
#include?"SIMS.h"struct?StudentMessageS?StudentMessage?=?{?0?};int?main()
{
?
?printf("*********学?生?信?息?管?理?系?统*********\n");
?printf("学生信息录入?:请按?1?\n");
?printf("学生信息浏览?:请按?2?\n");
?printf("按学号查询?:请按?3?\n");
?printf("按姓名查询?:请按?4?\n");
?printf("删除学生信息?:请按?5?\n");
?printf("修改学生信息?:请按?6?\n");
?printf("退出??:请按?0?\n");
?printf("*********学?生?信?息?管?理?系?统*********\n");
?int?Num?=?0;
?scanf("%d",?&Num);
?scanf("%*[^\n]");
?scanf("%*c");
?switch?(Num)
?{
?case?1:
??StudentMessageLogin();
??break;
?case?2:
??StudentMessageSee();
??break;
?case?3:
??StudentMessageQueryByNum();\
??break;
?case?4:
??StudentMessageQueryByName();
??break;
?case?5:
??DeleteStudentMessage();
??break;
?case?6:
??UpdateStudentMessage();
??break;
?case?0:
??exit(0);
??break;
?default:
??break;
?}
?getchar();
?return?0;
}//文件格式
//@StudentID#StudentNameStudentAge^StudentSex&StudentDate*StudentAddr~StudentPhone|StucentEmailint?MessageLogin()
{
?printf("请输入学号:");?scanf("%s",?&StudentMessage.StudentID);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");
?printf("请输入姓名:");?scanf("%s",?&StudentMessage.StudentName);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");
?printf("请输入年龄:");?scanf("%s",?&StudentMessage.StudentAge);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");
?printf("请输入性别:");?scanf("%s",?&StudentMessage.StudentSex);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");
?printf("请输入生日:");?scanf("%s",?&StudentMessage.StudentDate);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");
?printf("请输入地址:");?scanf("%s",?&StudentMessage.StudentAddr);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");
?printf("请输入电话:");?scanf("%s",?&StudentMessage.StudentPhone);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");
?printf("请输入邮箱:");?scanf("%s",?&StudentMessage.StucentEmail);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");?FILE?*file?=?fopen("StudentMessage",?"a+");
?if?(file?==?NULL)
?{
??printf("创建学生文件失败\n");
??return?-1;
?}
?fprintf(file,?"@%s#%s%s^%s&%s*%s~%s|%s\n",?StudentMessage.StudentID,?StudentMessage.StudentName,?StudentMessage.StudentAge,?StudentMessage.StudentSex,
??StudentMessage.StudentDate,?StudentMessage.StudentAddr,?StudentMessage.StudentPhone,?StudentMessage.StucentEmail);
?printf("%s?信息录入完成\n",?StudentMessage.StudentName);
?fclose(file);
?
}
int?StudentMessageLogin()
{
?MessageLogin();
?char?charStr[2];
?do?
?{
??memset(charStr,?0x00,?sizeof(charStr));
??printf("继续录入请按:a\n");
??printf("结束录入请问:b\n");
??scanf("%s",?&charStr);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");??if?(memcmp(charStr,?"a",?strlen("a"))?==?0)
??{
???MessageLogin();
??}?}?while?(memcmp(charStr,?"b",?strlen("b"))?!=?0);
?
?return?0;
}
int?StudentMessageSee()
{
?char?Buff[512]?=?{?0?};
?FILE?*file?=?fopen("StudentMessage",?"r+");
?if?(file?==?NULL)
?{
??printf("打开学生文件失败\n");
??return?-1;
?}
?while?(feof(file)==0)
?{
??memset(Buff,?0x00,?sizeof(Buff));
??fgets(Buff,?sizeof(Buff)-1,?file);
??if?(Buff[0]?==?NULL)
??{
???printf("读取完毕\n");
??}
??printf("%s\n",?Buff);
??return?0;
?}
?fclose(file);
?return?0;}
int?StudentMessageQueryByNum()
{
?printf("请输入学号\n");?scanf("%s",?&StudentMessage.StudentID);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");?char?Buff[512]?=?{?0?};
?char?*FindPosA?=?NULL;
?char?*FindPosB?=?NULL;
?char?StudenNum[30]?=?{?0?};
?FILE?*file?=?fopen("StudentMessage",?"r+");
?if?(file?==?NULL)
?{
??printf("打开学生文件失败\n");
??return?-1;
?}
?while?(feof(file)==0)
?{
??memset(Buff,?0x00,?sizeof(Buff));
??fgets(Buff,?sizeof(Buff)-1,?file);
??FindPosA?=?strchr(Buff,?'@');
??FindPosB?=?strchr(Buff,?'#');
??memcpy(StudenNum,?Buff+1,?FindPosB?-?FindPosA-1);
??if?(memcmp(StudenNum,?StudentMessage.StudentID,?FindPosB?-?FindPosA-1)?==?0)
??{
???printf("学生信息是:%s\n",?Buff);
???fclose(file);
???return?0;???
??}
?}
?printf("没有此学生信息\n");?fclose(file);
?return?0;
}
int?StudentMessageQueryByName()
{
?printf("请输入姓名\n");?scanf("%s",?&StudentMessage.StudentName);?scanf("%*[^\n]");?scanf("%*c");?printf("\n");?char?Buff[512]?=?{?0?};
?char?*FindPosA?=?NULL;
?char?*FindPosB?=?NULL;
?char?StudenName[30]?=?{?0?};
?FILE?*file?=?fopen("StudentMessage",?"r+");
?if?(file?==?NULL)
?{
??printf("打开学生文件失败\n");
??return?-1;
?}
?while?(feof(file)==0)
?{
??memset(Buff,?0x00,?sizeof(Buff));
??fgets(Buff,?sizeof(Buff)-1,?file);
??FindPosA?=?strchr(Buff,?'#');
??FindPosB?=?strchr(Buff,?'');
??memcpy(StudenName,?FindPosA+1,FindPosB?-?FindPosA-1);
??if?(memcmp(StudenName,?StudentMessage.StudentName,?FindPosB?-?FindPosA-1)?==?0)
??{
???printf("学生的信息是:%s\n",?Buff);
???return?0;
???fclose(file);
??}
?}
?printf("没有此学生信息\n");?fclose(file);
?return?0;
}
int?DeleteStudentMessage()
{
?return?0;
}
int?UpdateStudentMessage()
{
?return?0;
}?