資源簡介
unbantu 16.4 下用c語言實現的命令形式的航班管理系統,有乘客登錄,管理員登錄,通過文件保存航班和乘客信息

代碼片段和文件信息
#include?“Plane.h“
??extern??P_I?P;
??extern??M_I?M;
??extern??A_I?A;
?int?readtxt(P_I_P?headM_I_P?mheadA_I_P?ahead)?//read?the?book
{
FILE?*fp=fopen(“passanger.txt““r+“);
if(!fp)
{
perror(“passengeropen“);
return?-1;
}
FILE?*mp=fopen(“Manager.txt““r+“);
if(!mp)
{
perror(“maneropen“);
return?-1;
}
FILE?*ap=fopen(“Plane.txt““r+“);
if(!ap)
{
perror(“airplanopen“);
return?-1;
}
while(fread(&Psizeof(P)1fp))
{
//printf(“%s--%s--%s--%s--%s\n“P.nameP.ageP.sexP.accoutP.password);
????pinsert(head->prev&P);
}
while(fread(&Msizeof(M)1mp))
{
?//printf(“%s--%s--%s--%s--%s\n“M.MnameM.MageM.MsexM.MaccoutM.Mpassword);
????minsert(mhead->prev&M);
}
while(fread(&Asizeof(A)1ap))
{
?//printf(“%s--%s--%s--%s--%s\n“M.MnameM.MageM.MsexM.MaccoutM.Mpassword);
????ainsert(ahead->prev&A);
}
?????
a_travel(ahead);
????fclose(fp);
fclose(mp);
fclose(ap);
return?0;
//fgets();
}
int?writetxt(P_I_P?*pheadM_I_P?*mheadA_I_P?*ahead)
{
????? FILE?*fp=fopen(“passanger.txt““w+“);
????????if(!fp)
{
perror(“writepassengerfopen“);
return?-1;
???? }
FILE?*mp=fopen(“Manager.txt““w+“);
????????if(!mp)
????????{
???????? perror(“writeManagerfopen“);
????????return?-1;
}
????FILE?*ap=fopen(“Plane.txt““w+“);
if(!ap){
perror(“writePlanefopen“);
????return?-1;
}
?????????P_I_P?ph=(*phead)->nextp=NULL;
?
?while(ph!=*phead)
?{
strcpy(P.nameph->name);
strcpy(P.ageph->age);
strcpy(P.sexph->sex);
strcpy(P.accoutph->accout);
strcpy(P.passwordph->password);
????????????fwrite(&Psizeof(P)1fp);
?
p=ph;
ph=ph->next;
free(p);
?}
?p=ph=NULL;
?
?free(*phead);
?*phead=NULL;
?
?M_I_P?mh=(*mhead)->nextm=NULL;
?
?while(mh!=*mhead)
?{
????strcpy(M.Mnamemh->Mname);
strcpy(M.Magemh->Mage);
strcpy(M.Msexmh->Msex);
strcpy(M.Maccoutmh->Maccout);
strcpy(M.Mpasswordmh->Mpassword);
????????????fwrite(&Msizeof(M)1mp);
m=mh;
mh=mh->next;
free(m);
?}
?m=mh=NULL;
?
?free(*mhead);
?*mhead=NULL;
?
?
?
?A_I_P?ah=(*ahead)->nexta=NULL;
?
?while(ah!=*ahead)
?{
strcpy(A.pidah->pid);
strcpy(A.startplaceah->startplace);
strcpy(A.endplaceah->endplace);
strcpy(A.starttimeah->starttime);
strcpy(A.endtimeah->endtime);
????????????fwrite(&Asizeof(A)1ap);
?
a=ah;
ah=ah->next;
free(a);
?}
?a=ah=NULL;
?
?free(*ahead);
?*ahead=NULL;
?
?
?
?/*?strcpy(P.name“劉芳“);
?strcpy(P.age“34“);
?strcpy(P.sex“女“);
?strcpy(P.accout“123“);
?strcpy(P.password“123“);
?
?strcpy(M.Mname“魏總“);
?strcpy(M.Mage“34“);
?strcpy(M.Msex“男“);
?strcpy(M.Maccout“123“);
?strcpy(M.Mpassword“123“);?
?
?
?strcpy(A.pid“01“);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????12288??2018-09-26?23:01??JPlaneSystem\Plane\.Makefile.swp
?????文件??????23080??2018-09-26?22:54??JPlaneSystem\Plane\a.out
?????文件???????3597??2018-09-26?19:02??JPlaneSystem\Plane\data.c
?????文件???????5536??2018-09-26?22:51??JPlaneSystem\Plane\data.o
?????文件???????6322??2018-09-26?22:21??JPlaneSystem\Plane\list.c
?????文件???????6568??2018-09-26?22:51??JPlaneSystem\Plane\list.o
?????文件??????23112??2018-09-26?22:29??JPlaneSystem\Plane\main
?????文件????????504??2018-09-26?22:04??JPlaneSystem\Plane\main.c
?????文件???????1872??2018-09-26?22:51??JPlaneSystem\Plane\main.o
?????文件????????395??2018-09-26?23:00??JPlaneSystem\Plane\Makefile
?????文件?????????96??2018-09-26?19:17??JPlaneSystem\Plane\Manager.txt
?????文件???????4112??2018-09-26?22:15??JPlaneSystem\Plane\Manger.c
?????文件???????8528??2018-09-26?22:51??JPlaneSystem\Plane\Manger.o
?????文件??????????0??2018-09-21?15:44??JPlaneSystem\Plane\Manger.txt
?????文件????????192??2018-09-26?19:17??JPlaneSystem\Plane\passanger.txt
?????文件???????3042??2018-09-26?22:11??JPlaneSystem\Plane\Passenger.c
?????文件???????6472??2018-09-26?22:51??JPlaneSystem\Plane\Passenger.o
?????文件???????3103??2018-09-26?22:25??JPlaneSystem\Plane\Plane.h
?????文件????????208??2018-09-26?19:17??JPlaneSystem\Plane\Plane.txt
?????文件??????23080??2018-09-26?23:00??JPlaneSystem\Plane\Planesystem
?????文件???????3129??2018-09-26?22:08??JPlaneSystem\Plane\UI.c
?????文件???????6912??2018-09-26?22:51??JPlaneSystem\Plane\UI.o
?????文件??????59376??2018-09-26?23:50??JPlaneSystem\設計文檔.docx
?????目錄??????????0??2018-09-27?09:06??JPlaneSystem\Plane
?????目錄??????????0??2018-09-27?09:06??JPlaneSystem
-----------?---------??----------?-----??----
???????????????201524????????????????????25
評論
共有 條評論