commit
40e3c01582
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,96 @@
|
||||
# Microsoft Developer Studio Project File - Name="LZT" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=LZT - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "LZT.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "LZT.mak" CFG="LZT - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "LZT - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "LZT - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "LZT - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x804 /d "NDEBUG"
|
||||
# ADD RSC /l 0x804 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "LZT - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x804 /d "_DEBUG"
|
||||
# ADD RSC /l 0x804 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "LZT - Win32 Release"
|
||||
# Name "LZT - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "LZT"=".\LZT.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
Binary file not shown.
@ -0,0 +1,65 @@
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<h1>Build Log</h1>
|
||||
<h3>
|
||||
--------------------Configuration: LZT - Win32 Debug--------------------
|
||||
</h3>
|
||||
<h3>Command Lines</h3>
|
||||
Creating temporary file "C:\Users\279800~1\AppData\Local\Temp\RSPCFE1.tmp" with contents
|
||||
[
|
||||
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/LZT.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
|
||||
"E:\信息库\LZT\h.c"
|
||||
]
|
||||
Creating command line "cl.exe @C:\Users\279800~1\AppData\Local\Temp\RSPCFE1.tmp"
|
||||
<h3>Output Window</h3>
|
||||
Compiling...
|
||||
h.c
|
||||
E:\信息库\LZT\h.c(102) : error C2143: syntax error : missing ';' before 'if'
|
||||
E:\信息库\LZT\h.c(102) : error C2143: syntax error : missing ')' before 'if'
|
||||
E:\信息库\LZT\h.c(130) : error C2143: syntax error : missing ';' before 'if'
|
||||
E:\信息库\LZT\h.c(130) : error C2143: syntax error : missing ')' before 'if'
|
||||
E:\信息库\LZT\h.c(146) : error C2143: syntax error : missing ';' before 'if'
|
||||
E:\信息库\LZT\h.c(146) : error C2143: syntax error : missing ')' before 'if'
|
||||
E:\信息库\LZT\h.c(159) : error C2143: syntax error : missing ';' before '{'
|
||||
E:\信息库\LZT\h.c(159) : error C2143: syntax error : missing ')' before '{'
|
||||
E:\信息库\LZT\h.c(161) : error C2143: syntax error : missing ';' before 'if'
|
||||
E:\信息库\LZT\h.c(161) : error C2143: syntax error : missing ')' before 'if'
|
||||
E:\信息库\LZT\h.c(161) : error C2039: 'sum' : is not a member of 'student'
|
||||
E:\信息库\LZT\h.c(15) : see declaration of 'student'
|
||||
E:\信息库\LZT\h.c(162) : error C2143: syntax error : missing ')' before '{'
|
||||
E:\信息库\LZT\h.c(168) : error C2039: 'english' : is not a member of 'student'
|
||||
E:\信息库\LZT\h.c(15) : see declaration of 'student'
|
||||
E:\信息库\LZT\h.c(168) : error C2039: 'math' : is not a member of 'student'
|
||||
E:\信息库\LZT\h.c(15) : see declaration of 'student'
|
||||
E:\信息库\LZT\h.c(168) : error C2039: 'chinese' : is not a member of 'student'
|
||||
E:\信息库\LZT\h.c(15) : see declaration of 'student'
|
||||
E:\信息库\LZT\h.c(168) : error C2039: 'aver' : is not a member of 'student'
|
||||
E:\信息库\LZT\h.c(15) : see declaration of 'student'
|
||||
E:\信息库\LZT\h.c(168) : error C2039: 'sum' : is not a member of 'student'
|
||||
E:\信息库\LZT\h.c(15) : see declaration of 'student'
|
||||
E:\信息库\LZT\h.c(189) : error C2143: syntax error : missing ';' before 'if'
|
||||
E:\信息库\LZT\h.c(189) : error C2143: syntax error : missing ')' before 'if'
|
||||
E:\信息库\LZT\h.c(200) : error C2146: syntax error : missing ';' before identifier 'stu'
|
||||
E:\信息库\LZT\h.c(200) : error C2143: syntax error : missing ')' before ';'
|
||||
E:\信息库\LZT\h.c(206) : error C2146: syntax error : missing ';' before identifier 'getch'
|
||||
E:\信息库\LZT\h.c(249) : error C2143: syntax error : missing ';' before 'if'
|
||||
E:\信息库\LZT\h.c(249) : error C2143: syntax error : missing ')' before 'if'
|
||||
E:\信息库\LZT\h.c(249) : error C2065: 'name' : undeclared identifier
|
||||
E:\信息库\LZT\h.c(249) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
|
||||
E:\信息库\LZT\h.c(249) : warning C4024: 'strcmp' : different types for formal and actual parameter 2
|
||||
E:\信息库\LZT\h.c(261) : error C2065: 'a' : undeclared identifier
|
||||
E:\信息库\LZT\h.c(269) : error C2146: syntax error : missing ';' before identifier 'stu'
|
||||
E:\信息库\LZT\h.c(269) : error C2143: syntax error : missing ')' before ';'
|
||||
E:\信息库\LZT\h.c(291) : error C2084: function 'int __cdecl openl()' already has a body
|
||||
E:\信息库\LZT\h.c(319) : error C2084: function 'void __cdecl see()' already has a body
|
||||
E:\信息库\LZT\h.c(345) : fatal error C1004: unexpected end of file found
|
||||
Error executing cl.exe.
|
||||
|
||||
|
||||
|
||||
<h3>Results</h3>
|
||||
h.obj - 31 error(s), 2 warning(s)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,303 @@
|
||||
#include<stdio.h>
|
||||
#include<conio.h>
|
||||
#include<string.h>
|
||||
#include<stdlib.h>
|
||||
void look(); /*声明查看函数*/
|
||||
void save(); /*声明保存函数*/
|
||||
void search_name(); /*声明按姓名查看函数*/
|
||||
void search_number(); /*声明按学号查看函数*/
|
||||
void order(); /*声明排序函数*/
|
||||
void del(); /*声明删除函数*/
|
||||
int openl(); /*声明打开函数*/
|
||||
void type(); /*声明输入函数*/
|
||||
void see(); /*声明打开并查看文件函数*/
|
||||
struct student /*定义学生信息的结构体类型*/
|
||||
{
|
||||
char num[15]; /*学号*/
|
||||
char name[20]; /*姓名*/
|
||||
char sex[4]; /*性别*/
|
||||
char age[3]; /*年龄*/
|
||||
char ad[20]; /*地址*/
|
||||
char tel[20]; /*电话*/
|
||||
char E[20]; /*邮箱*/
|
||||
char year[20];/*年份*/
|
||||
char month[12];/*月份*/
|
||||
char day[30];/*日期*/
|
||||
}stu[100];
|
||||
int n; /*声明一个全局变量*/
|
||||
void main() /*主函数即用户的操作界面*/
|
||||
{
|
||||
int b,flag=0; /*声明局部变量*/
|
||||
while(1) /*循环输出以下信息*/
|
||||
{
|
||||
printf("\n\t\t\t欢迎来到学生信息管理系统!\n");
|
||||
printf("\n\t\t\t\t 刘紫婷制作\n");
|
||||
printf("\t\t\t-------------------------------\n");
|
||||
printf("\t\t\t1.录入学生的信息\n\n"); /*录入学生的信息*/
|
||||
printf("\t\t\t2.查看录入的学生信息\n\n"); /*查看录入的学生信息*/
|
||||
printf("\t\t\t3.按姓名查看学生的信息\n\n"); /*按姓名查看学生的信息*/
|
||||
printf("\t\t\t4.按学号查看学生的信息\n\n"); /*按学号查看学生的信息*/
|
||||
printf("\t\t\t5.按学号对学生信息排序\n\n"); /*排序*/
|
||||
printf("\t\t\t6.删除学生信息\n\n"); /*删除学生信息*/
|
||||
printf("\t\t\t7.保存学生信息\n\n"); /*保存*/
|
||||
printf("\t\t\t8.打开文件\n\n"); /*打开文件*/
|
||||
printf("\t\t\t0.退出\n\n"); /*退出*/
|
||||
printf("\t\t\t请输入你的选择:");
|
||||
scanf("%d",&b);
|
||||
switch(b)
|
||||
{
|
||||
case 1:type();break; /*调用录入学生信息函数*/
|
||||
case 2:look();break; /*调用查看函数*/
|
||||
case 3:search_name();break; /*调用姓名查看学生信息函数*/
|
||||
case 4:search_number();break; /*调用学号查看学生信息函数*/
|
||||
case 5:order();break; /*调用学号排序学生信息函数*/
|
||||
case 6:del();break;/*调用删除函数*/
|
||||
case 7:save();break;/*调用保存函数*/
|
||||
case 8:see();break;/*调用打开文件函数*/
|
||||
case 0:flag=1;break;/*退出SWITCH语句*/
|
||||
default :printf("错误!");
|
||||
}
|
||||
if(flag)
|
||||
break; /*如果选择0就退出循环*/
|
||||
}
|
||||
}
|
||||
void type() /*定义录入学生信息函数*/
|
||||
{
|
||||
int i; /*定义局部变量*/
|
||||
printf("\t\t输出你想输入的学生信息个数:");
|
||||
scanf("%d",&n);
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
printf("\n\t\t\t----------------\n");
|
||||
printf("\t\t\t学号:");
|
||||
scanf("%s",&stu[i].num); /*输入学号*/
|
||||
printf("\t\t\t姓名:");
|
||||
scanf("%s",&stu[i].name); /*输入姓名*/
|
||||
printf("\t\t\t性别:");
|
||||
scanf("%s",&stu[i].sex); /*输入性别*/
|
||||
printf("\t\t\t年龄:");
|
||||
scanf("%s",&stu[i].age); /*输入年龄*/
|
||||
printf("\t\t\t地址:");
|
||||
scanf("%s",&stu[i].ad); /*输入地址*/
|
||||
printf("\t\t\t电话:");
|
||||
scanf("%d",&stu[i].tel); /*输入电话*/
|
||||
printf("\t\t\tE-mail:");
|
||||
scanf("%s",&stu[i].E);/*输入E-mail*/
|
||||
printf("\t\t\t年份:");
|
||||
scanf("%s",&stu[i].year);/*输入年份*/
|
||||
}
|
||||
printf("\n\n\t\t\t按任意键返回菜单!!");
|
||||
getchar();
|
||||
save();
|
||||
}
|
||||
void save() /*建立保存文件函数*/
|
||||
{
|
||||
FILE *fp; /*定义文件型指针*/
|
||||
int i;
|
||||
if((fp=fopen("student.txt","wb"))==NULL) /*打开输出文件*/
|
||||
{
|
||||
printf("不能打开文件!\n");
|
||||
return; /*终止程序*/
|
||||
}
|
||||
for(i=0;i
|
||||
if(fwrite(&stu[i],sizeof(struct student),1,fp)!=1)
|
||||
printf("文件写入错误\n");
|
||||
fclose(fp); /*关闭文件*/
|
||||
printf("\n\n\n\n\t\t\t学生信息保存成功!\n");
|
||||
printf("\n\n\n\n\t\t\t按任意键返回菜单!!");
|
||||
getch();
|
||||
}
|
||||
void look() /*定义查看函数*/
|
||||
{
|
||||
int i;
|
||||
n=openl(); /*调用openl函数*/
|
||||
printf("\t学号\t姓名\t性别\t年龄\t地址\t电话\tE-mail\t年\t月\t日\n");
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[i].num,stu[i].name,
|
||||
stu[i].sex,stu[i].age,stu[i].ad,stu[i].tel,stu[i].E,stu[i].year,stu[i].month,stu[i].day);
|
||||
}
|
||||
printf("\n\n\n\t\t\t按任意键返回菜单");
|
||||
getchar();
|
||||
}
|
||||
void search_name() /*按姓名查看函数*/
|
||||
{
|
||||
int i;
|
||||
char name[20]; /*声明字符数组*/
|
||||
printf("\t\t\t请输入学生姓名:\n");
|
||||
scanf("%s",name);
|
||||
printf("\t学号\t姓名\t性别\t年龄\t地址\t电话\tE-mail\t年\t月\t日\n");
|
||||
for(i=0;i
|
||||
if(strcmp(stu[i].name,name)==0) /*将输入的姓名与结构体中的姓名进行比较*/
|
||||
{
|
||||
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[i].num,stu[i].name,
|
||||
stu[i].sex,stu[i].age,stu[i].ad,stu[i].tel,stu[i].E,stu[i].year,stu[i].month,stu[i].day);
|
||||
printf("\n\n\n\t\t\t按任意键返回菜单");
|
||||
}
|
||||
getchar();
|
||||
}
|
||||
void search_number() /*定义按学号查看函数*/
|
||||
{
|
||||
int i;
|
||||
char number[15]; /*声明字符数组*/
|
||||
printf("\t\t\t请输入学号:\n");
|
||||
scanf("%s",number);
|
||||
printf("\t学号\t姓名\t性别\t年龄\t地址\t电话\tE-mail\t年\t月\t日\n");
|
||||
for(i=0;i
|
||||
if(strcmp(stu[i].num,number)==0) /*将输入的学号与结构体中的学号进行比较*/
|
||||
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[i].num,stu[i].name,
|
||||
stu[i].sex,stu[i].age,stu[i].ad,stu[i].tel,stu[i].E,stu[i].year,stu[i].month,stu[i].day);
|
||||
printf("\n\n\n\t\t\t按任意键返回菜单");
|
||||
getch();
|
||||
}
|
||||
void order() /*定义排序函数*/
|
||||
{
|
||||
int i,j;
|
||||
char a;
|
||||
struct student temp; /*声明结构体变量*/
|
||||
printf("\t学号\t姓名\t性别\t年龄\t地址\t电话\tE-mail\t年\t月\t日\n");
|
||||
for(i=0;i
|
||||
{
|
||||
for(j=i+1;j
|
||||
if(stu[i].sum
|
||||
{
|
||||
temp=stu[i];
|
||||
stu[i]= stu[j];
|
||||
stu[j]=temp;
|
||||
}
|
||||
printf("%10s\t%s\t%2s\t%d\t%d\t%d\t%3.1f\t\t%6.1f\n",stu[i].num,stu[i].name,
|
||||
stu[i].sex,stu[i].english,stu[i].math,stu[i].chinese,stu[i].aver,stu[i].sum);
|
||||
}
|
||||
getch();
|
||||
printf("是否保存?(y or n)");
|
||||
getchar();
|
||||
scanf("%c",&a);
|
||||
if(a=='y') /*是否保存排序后的文件*/
|
||||
save();
|
||||
else
|
||||
printf("退出");
|
||||
getchar();
|
||||
}
|
||||
void del() /*定义删除学生信息函数*/
|
||||
{
|
||||
int i;
|
||||
char a;
|
||||
char name[20];
|
||||
printf("\t\t\t输入学生名字:\n");
|
||||
scanf("%s",name);
|
||||
printf("\t学号\t姓名\t性别\t年龄\t地址\t电话\tE-mail\t年\t月\t日\n");
|
||||
for(i=0;i
|
||||
if(strcmp(stu[i].name,name)==0)
|
||||
{
|
||||
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[i].num,stu[i].name,
|
||||
stu[i].sex,stu[i].age,stu[i].ad,stu[i].tel,stu[i].E,stu[i].year,stu[i].month,stu[i].day);
|
||||
getch();
|
||||
printf("真的删除?(y or n)");
|
||||
getchar();
|
||||
scanf("%c",&a);
|
||||
if(a=='y') /*是否删除该信息*/
|
||||
{
|
||||
for(;i
|
||||
stu[i]=stu[i+1];
|
||||
n=n-1;
|
||||
printf("你已经删除信息");
|
||||
}
|
||||
else
|
||||
printf("退出")
|
||||
getch();
|
||||
}
|
||||
save();
|
||||
}
|
||||
int openl() /*定义打开文件函数*/
|
||||
{
|
||||
int i;
|
||||
FILE *fp;
|
||||
if((fp=fopen("student.txt","rb"))==NULL)
|
||||
{
|
||||
("Cannot open file.\n");
|
||||
exit(0);
|
||||
}
|
||||
for(i=0;!feof(fp);i++)
|
||||
fread(&stu[i],sizeof(struct student),1,fp);
|
||||
fclose(fp);
|
||||
return(i-1);
|
||||
}
|
||||
void see() /*打开并查看文件*/
|
||||
{
|
||||
int i;
|
||||
n=openl();
|
||||
printf("文件打开成功!\n");
|
||||
printf("按任意键查看!\n");
|
||||
getch();
|
||||
printf("\t学号\t姓名\t性别\t年龄\t地址\t电话\tE-mail\t年\t月\t日\n");
|
||||
for(i=0;i
|
||||
if(strcmp(stu[i].name,name)==0)
|
||||
{
|
||||
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].age,stu[i].ad,stu[i].tel,stu[i].E,stu[i].year,stu[i].month,stu[i].day);
|
||||
getch();
|
||||
printf("真的删除?(y or n)");
|
||||
getchar();
|
||||
scanf("%c",&a);
|
||||
if(a=='y') /*是否删除该信息*/
|
||||
{
|
||||
for(;i
|
||||
stu[i]=stu[i+1];
|
||||
n=n-1;
|
||||
printf("你已经删除信息");
|
||||
}
|
||||
else
|
||||
printf("退出");
|
||||
getch();
|
||||
}
|
||||
save();
|
||||
}
|
||||
int openl() /*定义打开文件函数*/
|
||||
{
|
||||
int i;
|
||||
FILE *fp;
|
||||
if((fp=fopen("student.txt","rb"))==NULL)
|
||||
|
||||
{
|
||||
|
||||
printf("Cannot open file.\n");
|
||||
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
for(i=0;!feof(fp);i++)
|
||||
|
||||
fread(&stu[i],sizeof(struct student),1,fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return(i-1);
|
||||
|
||||
}
|
||||
|
||||
void see() /*打开并查看文件*/
|
||||
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
n=openl();
|
||||
|
||||
printf("文件打开成功!\n");
|
||||
|
||||
printf("按任意键查看!\n");
|
||||
|
||||
getch();
|
||||
|
||||
printf("\t学号\t姓名\t性别\t年龄\t地址\t电话\tE-mail\t年\t月\t日\n");
|
||||
|
||||
for(i=0;i<n;i++)
|
||||
|
||||
{
|
||||
|
||||
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",stu[i].num,stu[i].name,
|
||||
|
||||
stu[i].sex,stu[i].age,stu[i].ad,stu[i].tel,stu[i].E,stu[i].year,stu[i].month,stu[i].day);
|
||||
}
|
||||
printf("\n\n\n\t\t\t按任意键返回菜单");
|
||||
getchar();
|
Loading…
Reference in new issue