You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
2.5 KiB
172 lines
2.5 KiB
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
struct student
|
|
{ char num[20];
|
|
char name[20];
|
|
int age;
|
|
char sex[7];
|
|
char birthday[20];
|
|
char address[100];
|
|
char phone[15];
|
|
char email[30];
|
|
}stu;
|
|
|
|
void welcome()
|
|
{
|
|
printf(" 欢迎进入 \n");
|
|
printf("******************学生信息管理系统**********************\n");
|
|
printf(" 1.学生信息录入 \n");
|
|
printf(" 2.学生信息浏览 \n");
|
|
printf(" 3.查询,排序 \n");
|
|
printf(" 4.学生信息的删除与修改 \n");
|
|
printf("********************************************************\n");
|
|
printf(" 请输入所需功能的序号!!! \n");
|
|
}
|
|
|
|
void First()
|
|
{ int i=1;
|
|
char ch;
|
|
FILE *fp;
|
|
if((fp=fopen("a.txt","ab+"))==NULL)
|
|
{
|
|
printf("cannot open file\n");
|
|
exit(0);
|
|
}
|
|
do
|
|
{
|
|
|
|
printf("请输入学生信息\n");
|
|
printf("学号\n");
|
|
scanf("%s",stu.num);
|
|
printf("姓名\n");
|
|
scanf("%s",stu.name);
|
|
printf("年龄\n");
|
|
scanf("%d",&stu.age);
|
|
do
|
|
{
|
|
printf("性别(man/woman)\n");
|
|
scanf("%s",stu.sex);
|
|
if((strcmp(stu.sex,"man"))&&(strcmp(stu.sex,"woman")))
|
|
{
|
|
printf("输入有误,请按正确格式输入!");
|
|
continue;
|
|
}
|
|
i=0;
|
|
}while(i);
|
|
|
|
printf("出生日期(####/##/##)\n");
|
|
scanf("%s",stu.birthday);
|
|
printf("地址\n");
|
|
scanf("%s",stu.address);
|
|
printf("电话\n");
|
|
scanf("%s",stu.phone);
|
|
printf("邮箱\n");
|
|
scanf("%s",stu.email);
|
|
if(fwrite(&stu,sizeof(struct student),1,fp)!=1)
|
|
{
|
|
printf("file write error\n");
|
|
exit(0);
|
|
}
|
|
printf("是否继续录入?(y/n)\n");
|
|
getchar();
|
|
ch=getchar();
|
|
}
|
|
while(ch=='y');
|
|
if(fclose(fp))
|
|
{
|
|
printf("can not close the file!\n");
|
|
exit(0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Second()
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void Third()
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void Fourth()
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
{ int chose;
|
|
int n=1;
|
|
welcome();
|
|
scanf("%d",&chose);
|
|
while(n)
|
|
{
|
|
switch(chose)
|
|
{
|
|
case 1:First();break;
|
|
case 2:Second();break;
|
|
case 3:Third();break;
|
|
case 4:Fourth();break;
|
|
default:printf("输入有误,请重新输入正确的序号。");break;
|
|
}
|
|
n=0;
|
|
}
|
|
|
|
|
|
}
|
|
|