Linux下学生信息管理系统Word下载.docx
- 文档编号:19521782
- 上传时间:2023-01-07
- 格式:DOCX
- 页数:48
- 大小:26.22KB
Linux下学生信息管理系统Word下载.docx
《Linux下学生信息管理系统Word下载.docx》由会员分享,可在线阅读,更多相关《Linux下学生信息管理系统Word下载.docx(48页珍藏版)》请在冰豆网上搜索。
|---1.基本信息插入.-----2.基本信息修改----------|\n"
|---3.基本信息删除.-----4.基本信息显示----------|\n"
|---r.初始化(第一次使用时用!
!
慎用)-q.退出---|\n"
|--------------------请输入你的选择:
-----------|\n"
}
voidmain()
{
commanddisp();
charch;
while
(1)
{
do{
ch=getchar();
}while(ch=='
\n'
if(ch=='
q'
)return;
switch(ch)
{
case'
1'
:
inputstu();
break;
2'
updatestu();
3'
deletestu();
4'
displaystu();
r'
printf("
\ninitstudenttable\n"
if((out=fopen("
c.doc"
"
w"
))==NULL)return;
number=0;
fwrite(&
number,sizeof(unsignedint),1,out);
fflush(out);
fclose(out);
break;
default:
}
printf("
pleaseenteranykeytocontinue"
getchar();
system("
clear"
commanddisp();
}
voidinputstu()
\n-----------------请输入学生信息----------------------\n"
charp='
y'
;
while(p=='
||p=='
Y'
)
memset(&
student,0,sizeof(student));
学号:
"
scanf("
%s"
student.stu_num);
姓名:
student.name);
性别<0是女,1是男>:
student.sex=getchar();
}while(student.sex=='
手机号:
student.mobile_phone);
len=sizeof(structstu_info);
if((out=fopen("
r+"
fread(&
number++;
fseek(out,0L,SEEK_SET);
fwrite(&
fflush(out);
fseek(out,0L,SEEK_END);
student,len,1,out);
fclose(out);
是否继续输入Y/N\n"
fflush(stdin);
p=getchar();
}while(p=='
voidupdatestu()
\n-------------------学生信息修改-------------------------\n"
请输入修改学生的学号:
memset(&
scanf("
do{
student.sex=getchar();
}while(student.sex=='
len=sizeof(structstu_info);
in=fopen("
fread(&
number,sizeof(unsignedint),1,in);
unsignedintj;
longkk;
for(j=0;
j<
number;
j++)
stu[0],len,1,in);
if(strcmp(student.stu_num,stu[0].stu_num)==0)
{kk=len;
fseek(in,-kk,SEEK_CUR);
student,len,1,in);
fflush(in);
fclose(in);
if(j==number)printf("
没有这条记录\n"
voiddeletestu()
\n-------------------学生信息删除-------------------------\n"
r"
memset(stu,0,sizeof(stu));
fread(stu,len,number,in);
unsignedinti;
charf;
请输入删除学生的学号:
charstu_num[12];
memset(stu_num,0,sizeof(stu_num));
stu_num);
for(i=0;
i<
i++)
if(strcmp(stu_num,stu[i].stu_num)==0)break;
if(i==number)printf("
else
number--;
for(;
{
strcpy(stu[i].stu_num,stu[i+1].stu_num);
strcpy(stu[i].name,stu[i+1].name);
stu[i].sex=stu[i+1].sex;
strcpy(stu[i].mobile_phone,stu[i+1].mobile_phone);
}
是否继续删除Y/N\n"
f=getchar();
}while(f=='
if(f!
='
&
f!
)break;
out=fopen("
fwrite(&
len=len*number;
fwrite(stu,len,1,out);
fflush(out);
fclose(out);
voiddisplaystu()
\n------------------------------显示学生信息----------------------------------\n"
----------------------------------------------------------------------------\n"
number\t学号\t姓名\t性别<
0是女,1是男>
手机号\n"
for(i=0;
%3d%12s%10s%c%12s\n"
i,stu[i].stu_num,stu[i].name,stu[i].sex,stu[i].mobile_phone);
利用父子进程间的管道通信方式,改写实验3步骤6要求的程序。
要求启用两个进程,其中父进程接受用户对文件stu.info的操作命令然后通过管道发给子进程,子进程完成对文件的实际操作。
intpipefiles[2];
------------------------------------------------\n"
|----------学生基本信息管理---------------|\n"
|--1.基本信息插入.-----2.基本信息修改--------|\n"
|--3.基本信息删除.-----4.基本信息显示--------|\n"
|--r.初始化(第一次使用时用!
慎用)--------|\n"
-----|\n:
pid_tpid;
FILE*in;
FILE*out;
intlen;
if(pipe(pipefiles)==0)
pid=fork();
if(pid==-1)
fprintf(stderr,"
Forkfailure\n"
return;
if(pid==0)////child.
read(pipefiles[0],&
ch,1);
while
(1)
sleep
(1);
len=sizeof(structstu_info);
char*ch1=(char*)malloc(sizeof(char)*len);
read(pipefiles[0],ch1,len);
if((out=fopen("
fread(&
number++;
fseek(out,0L,SEEK_SET);
fwrite(&
fclose(out);
a"
fwrite(ch1,len,1,out);
charf;
read(pipefiles[0],&
f,sizeof(char));
if(f!
)return;
student,len);
in=fopen("
memset(stu,0,sizeof(stu));
fread(stu,len,number,in);
unsignedintj;
for(j=0;
if(strcmp(student.stu_num,stu[j].stu_num)==0)
{
strcpy(stu[j].name,student.name);
stu[j].sex=student.sex;
strcpy(stu[j].mobile_phone,student.mobile_phone);
break;
}
fclose(in);
if(j==number)printf("
else
{
out=fopen("
fwrite(&
len=len*number;
stu,len,1,out);
fclose(out);
}
charstu_num[12];
memset(stu_num,0,sizeof(stu_num));
read(pipefiles[0],stu_num,sizeof(stu_num));
unsignedinti;
for(i=0;
if(i==number)printf("
else
for(;
number-1;
strcpy(stu[i].stu_num,stu[i+1].stu_num);
strcpy(stu[i].name,stu[i+1].name);
stu[i].sex=stu[i+1].sex;
strcpy(stu[i].mobile_phone,stu[i+1].mobile_phone);
if((out=fopen("
fread(&
number--;
fwrite(stu,len,1,out);
}
f,sizeof(int));
sleep
(1);
in=fopen("
fread(&
memset(stu,0,sizeof(stu));
fread(stu,len,number,in);
for(i=0;
printf("
-%d--学号:
%s-姓名:
%s-性别<
:
%c-手机号:
%s-\n"
fclose(in);
break;
default:
else////father.
write(pipefiles[1],&
case'
charp='
while(p=='
memset(&
scanf("
scanf("
do{
student.sex=getchar();
}while(student.sex=='
write(pipefiles[1],&
fflush(stdin);
p=getchar();
}while(p=='
p,sizeof(char));
break;
\n-------------------学生信息
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Linux 学生 信息管理 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)