版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
//last#include〈stdio。h〉include〈string.h〉#include〈stdlib.h〉include<conio.h>#define HEADER1 STUDENT \n"defineHEADER2” |numberInameIsexI\n"defineHEADERS” | I I I\n”defineFORMAT”姓名:%-6s\n性別:%-6s\n學(xué)號(hào):%-6s\n\n”#define END \n"#defineDATAtemp.Name,temp。Num,temp。Sextypedefstruct_Student{charName[12];charSex[4];charNum[20];}Student;voidMenu(FILE*);voidLuRu(FILE*);voidSeekStudent(FILE*);voidQingKong(FILE*);voidJiaMi(char*,int);voidJieMi(char*,int);voidDelete(FILE*);voidUpDate(FILE*);voidJudgeFP(FILE*);intFileSize(FILE*);voidDisPlay(FILE*fp);intmain(){FILE*fp;intchoice;fp=fopen("student.txt","ab+");JudgeFP(fp);fp=fopen("student.txt","rb+");JudgeFP(fp);if(fp==NULL){printf("ERROR!\n");exit(0);)while(1){system("cls");Menu(fp);scanf("%d”,&choice);switch(choice){case0:break;case1:LuRu(fp);break;case2:SeekStudent(fp);break;case3:QingKong(fp);break;case4:Delete(fp);break;case5:UpDate(fp);break;case6:DisPlay(fp);break;default:printf("輸入錯(cuò)誤\n”);)if(choice==0)break;printf("任意鍵返回主菜單");getch();fflush(stdin);)fclose(fp);return0;)voidLuRu(FILE*fp)〃錄入{Studenttemp;charch;do{printf("姓名:");scanf("%s",temp.Name);printf("性別:");scanf("%s",temp。Sex);printf("編號(hào):”scanf("%s",tempoNum);fseek(fp,0L,SEEK_END);//JiaMi((char*)&temp,sizeof(Student));fwrite(&temp,sizeof(Student),1,fp);printf("任意鍵繼續(xù)錄入0跳出\n");fflush(stdin);}while((ch=getch())!=’0’);)voidQingKong(FILE*fp)//清空數(shù)據(jù){if((fp=fopen("student。txt","wb"))==NULL)(printf("ERROR!\n");return;)printf("數(shù)據(jù)已清空\n”);}voidSeekStudent(FILE*fp)〃查詢{Studenttemp;charin[20];inti=0,j;printf("輸入姓名或者學(xué)號(hào)查詢:\n”);scanf("%s",in);rewind(fp);for(j=0;j(FileSize(fp);j++)(while(!feof(fp))(fseek(fp,j*sizeof(Student),SEEK_SET);fread(&temp,sizeof(Student),1,fp);break;)//JieMi((char*)&temp,sizeof(Student));if(strcmp(in,temp.Name)==0I|strcmp(in,temp.Num)==0)(printf(FORMAT,DATA}i=1;))if(i==0)printf("沒找到\n");)voidDelete(FILE*fp)//刪除{Studenttemp, del;Studentblank={"0","0","0"};charin[20];intmycount=0,i=0,j;if(FileSize(fp)==0){printf("無記錄可刪\n”);return;)if(FileSize(fp)==1){QingKong(fp);printf("刪除成功\n”);return;}printf("輸入要?jiǎng)h除的學(xué)號(hào)或者姓名:”);scanf("%s", in);fseek(fp, (FileSize(fp)—1)*sizeof(Student),SEEK_SET);fread(&temp,sizeof(Student), 1,fp);rewind(fp);for(j=0;j<FileSize(fp);j++){while(!feof(fp)){fseek(fp,j*sizeof(Student), SEEK_SET);fread(&del,sizeof(Student),1,fp);mycount++;break;)if(strcmp(in,del.Num)==0IIstrcmp(in,del。Name)==0){printf(FORMAT,del。Name,del。Num,del。Sex);fseek(fp, (mycount-1)*sizeof(Student),SEEK_SET);fwrite(&temp,sizeof(Student),1,fp);fseek(fp, (FileSize(fp)—1)*sizeof(Student),SEEK_SET);fwrite(&blank,sizeof(Student), 1,fp);printf("刪除成功\n");i=1;break;))if(i==0)printf("刪除失敗\n");)voidUpDate(FILE*fp)〃修改記錄{Studenttemp;charin[20];intmycount=0,i=0, j,k;if(FileSize(fp)==0)(printf("無記錄可修改\n”);return;)if(FileSize(fp)==1){QingKong(fp);printf("刪除成功\n");return;)printf("輸入要修改的學(xué)號(hào)或者姓名:“);scanf("%s",in);rewind(fp);for(j=0;j〈FileSize(fp);j++)(while(!feof(fp)){mycount++;fseek(fp,j*sizeof(Student),SEEK_SET);fread(&temp,sizeof(Student), 1,fp);break;)if(strcmp(in,temp。Num)==0|Istrcmp(in,temp。Name)==0){printf(FORMAT,DATA)printf("請(qǐng)選擇修改位置:1姓名2學(xué)號(hào)3性別4都修改0放棄修改\n");scanf("%d",&k);fflush(stdin);while(1){if(k==0){printf("成功放棄修改\n");return;}if(k>0&&k〈5)break;printf("輸入錯(cuò)誤,請(qǐng)重新輸入:\n");scanf(”%d”,&k);fflush(stdin);)if(k==1)(printf("姓名:");scanf("%s",tempoName);)if(k==2){printf("學(xué)號(hào):");scanf("%s”,temp.Num);)if(k==3){printf("性別:");scanf("%s”,tempoSex);)if(k==4){printf("姓名:“);scanf("%s",temp.Name);printf("學(xué)號(hào):");scanf("%s",tempoNum);printf("性別:");scanf("%s",temp.Sex);}fseek(fp, (mycount-1)*sizeof(Student),SEEK_SET);fwrite(&temp,sizeof(Student),1,fp);printf("修改成功\n");=1;//break;))if(i==0)printf("修改失敗\n");)intFileSize(FILE*fp)〃人數(shù)統(tǒng)計(jì)(intbegin,end,filesize;fseek(fp,0,SEEK_SET);begin=ftell(fp);fseek(fp,0,SEEK_END);end=ftell(fp);filesize=(end—begin)/sizeof(Student);returnfilesize;)voidJiaMi(char*p, intsize){inti;for(i=0; i<=size; i++)(%p=~(*p);p++;))voidJieMi(char*p, intsize){inti;for(i=0;i<=size;i++){*p=?(*p);p++;))voidJudgeFP(FILE*fp){if(fp==NULL){printf("ERROR!\n");exit(0);))voidMenu(FILE*fp)〃菜單(printf("\t\t\t學(xué)生信息管理系統(tǒng)歡迎您\n”);printf("\2\21.錄入數(shù)據(jù)\n");printf("\t\t\t\t2.查詢信息\n”);printf("\t\t\t\t3.清空數(shù)據(jù)\n");printf("\t\t\t\t4.刪除個(gè)人\n");printf("\t\t\t\t5。修改個(gè)人\n");printf("\t\t\t\t6。全部打印\n”);printf("\t\t\t\t0。退出系統(tǒng)\n”);printf("count:%d\n",
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 家庭醫(yī)生簽約服務(wù)工作實(shí)施方案
- 2025年人工智能工程師職業(yè)能力考核試題及答案
- 土方開挖施工安全保證措施
- 2025年衛(wèi)生計(jì)生監(jiān)督協(xié)管培訓(xùn)考試題及答案
- 學(xué)校義務(wù)教育均衡發(fā)展實(shí)施方案
- 建設(shè)工程施工合同糾紛要素式起訴狀模板新手也能輕松搞定
- 鋼結(jié)構(gòu)工程糾紛專用!建設(shè)工程施工合同糾紛要素式起訴狀模板
- 2026年保險(xiǎn)規(guī)劃指導(dǎo)課程
- 2026 年無子女離婚協(xié)議書法定版
- 2026 年離婚協(xié)議書正式版
- 食品安全管理制度打印版
- 多聯(lián)機(jī)安裝施工方案
- 煤礦副斜井維修安全技術(shù)措施
- 公共視頻監(jiān)控系統(tǒng)運(yùn)營(yíng)維護(hù)要求
- 河南省職工養(yǎng)老保險(xiǎn)參保人員關(guān)鍵信息變更核準(zhǔn)表
- 四川大學(xué)宣傳介紹PPT
- 小學(xué)數(shù)學(xué)人教版六年級(jí)上冊(cè)全冊(cè)電子教案
- 液氨儲(chǔ)罐區(qū)風(fēng)險(xiǎn)評(píng)估與安全設(shè)計(jì)
- 阿司匹林在一級(jí)預(yù)防中應(yīng)用回顧
- 2023年福??h政務(wù)中心綜合窗口人員招聘筆試模擬試題及答案解析
- GB/T 4103.10-2000鉛及鉛合金化學(xué)分析方法銀量的測(cè)定
評(píng)論
0/150
提交評(píng)論