指導個人日記管理系統(tǒng)(C語言)_第1頁
指導個人日記管理系統(tǒng)(C語言)_第2頁
指導個人日記管理系統(tǒng)(C語言)_第3頁
指導個人日記管理系統(tǒng)(C語言)_第4頁
指導個人日記管理系統(tǒng)(C語言)_第5頁
已閱讀5頁,還剩28頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

1、個人日記管理系統(tǒng)(C語言)# include# include# include# include# include# include/*宏定義ESC和Enter鍵的ascii值分別是27和13 */#define Esc 27#define Enter 13/*日記結(jié)點類型*/ typedef struct diary char date15; /日記日期 char title20; /日記標題 int flag; /用來標記該日記是否滿足查閱要求,滿足為-1,初始值為0; struct diary *next;DiaryNode; /*用戶結(jié)點類型 */ typedef struct us

2、er char user_name20; /用戶名 char password20; /密碼 int count; /存儲相應用戶的日期篇數(shù) DiaryNode *firstedge; struct user *next; *userList,userNode; /*函數(shù)聲明*/ void Show_Interface();void Version_file();userList Init_user();void main_meno(userList L); void User_Login(userList L);userList User_apply(userList L);void Hel

3、p_file();void User_Operate(userNode *H,userList L);void Write_dairy(userNode *H,userList L);int Search_dairy(userNode *H,char temp); void Read_dairy(char dairy_name);void Delete_dairy(userNode *H,userList L);void Rejigger_user_password(userNode *H,userList L);void Consult_dairy_meno(userNode *H); vo

4、id Consult_dairy(userNode *H,int i); void Express_chage_dark(char temp);void Dark_chage_express(char temp);void Password_input(char temp);void Save_user(userList L);void Save_dairy(userNode *H);/保存文件 /*/ /*歡迎界面*/void Show_Interface()char xx1080;char res80;int t=10;int i,m,a,b,c;strcpy(xx0,tttPersona

5、l Diary Management Systemn);strcpy(xx1,ttttAlgorithm Design:soulenvyn);strcpy(xx2,ttttCode Editor:soulenvyn);strcpy(xx3,ttttFrame Design:Palon);strcpy(xx4,ttttTest:soulenvy&Palon);strcpy(xx5,ttttVersion 1.0n);strcpy(xx6,ttttPublish:B.S.Pn);strcpy(xx7,ttttJune 8th 2011n);dofor(i=0;i80;i+) printf(*);p

6、rintf(%s,xx0);for(i=0;i=1&a=1&b=1&c0);void Version_file() FILE *fp; char c; system(cls); Sleep(500); fp=fopen(version.txt,r); /以只讀的方式打開文件,將文件指針賦給fp if(fp=NULL) printf (n-?- THE FILE CAN NOT BE OPENED.); return ; while(feof(fp)=0) c=fgetc(fp); /將文件中的字符讀入 printf(%c,c); Sleep(25); fclose(fp); printf(nn

7、t); system(pause); /*查閱日記操作*/void Consult_dairy(userNode *H,int i) DiaryNode *p; FILE *fp; char temp20; int j; int flag=0; p=H-firstedge; if (i=-1) /進行順序查詢 printf(nn-?- Please input the number of diary:n- ); scanf(%d,&j); if (jcount) while(j1) p=p-next; j-; p-flag=-1; /找到符合條件日記,對應結(jié)點的flag賦為-1,以便待會篩選出

8、來 flag=1; else if (i=0) printf(n-?- Please input the time:n- ); /進行日期查詢 if (i=15) printf(n-?- Please input the theme:n- ); /進行關鍵字查詢 scanf(%s,temp); rewind(stdin); while(p!=NULL) if(strstr(p-date+i),temp)!=NULL) p-flag=-1; flag=1; /找到符合條件的結(jié)點,其flag賦予-1,以便待會篩選出來 p=p-next; if(flag=0) printf(ntt#SORRY,TH

9、E DIARY CAN NOT BE FOUND#); else p=H-firstedge; printf(ntThe diaries are:n); chdir(H-user_name); while(p!=NULL) if(p-flag=-1) printf(ntn); printf(ttName:%sttTime%sn,p-title,p-date); p-flag=0; /篩選輸出結(jié)點的flag為-1的日記名,日期 Read_dairy(p-title); p=p-next; chdir(.); printf(nntt); system(pause); /*查閱日記菜單*/void

10、Consult_dairy_meno(userNode *H) char choice; printf(nnt |n); printf(t |1.By ordert2.By timet3.By theme tt|n); printf(t |n); printf(n-?- Choose an item(Esc for quit)n- ); choice=getche(); if (choice=Esc) return; switch(choice) case1: Consult_dairy(H,-1);break; case2: Consult_dairy(H,0);break; case3:

11、Consult_dairy(H,15);break; /*刪除用戶日記操作*/void Delete_dairy(userNode *H,userList L) DiaryNode *p; /指向要刪除的結(jié)點 DiaryNode *pre; /指向要刪除的結(jié)點的前驅(qū)結(jié)點 int i,j; char flag; printf(nn-?- Please input the number to delete:n- ); scanf(%d,&i); rewind(stdin); j=i; p=H-firstedge; while(i1) p=p-next; i-; p-flag=-1; /要刪除的結(jié)點

12、的flag標識符設為-1 p=H-firstedge; while(p!=NULL&(p-flag=0) pre=p; p=p-next; printf(n-$- You want to delete this diary:n); printf(ttNumber:%dt Name:%stTime:%s,j,p-title,p-date); printf(nDo you want to delete this diary:(Y or N) t); scanf(%c,&flag); rewind(stdin); if(flag=Y|flag=y) if(H-firstedge=p) H-first

13、edge=p-next; /要刪除的結(jié)點為第一結(jié)點時 else pre-next=p-next; /要刪除的結(jié)點不是第一結(jié)點時 else return ; chdir(H-user_name); /把相應用戶的目錄弄為當前工作目錄 H-count-; /用戶的日記數(shù)減1 remove(p-title); /去掉相應的文件 free(p); /釋放要刪除的結(jié)點空間 Save_dairy(H); /保存用戶日記信息,不然原有的用戶日記信息還是不變 Save_user(L); /保存用戶信息 printf(ntDeleting,please wait.); Sleep(1000); printf(n

14、ntThe diary has delete!nt); system(pause); /*密文轉(zhuǎn)換成明文*/void Dark_chage_express(char temp) int i; i=0; while(tempi!=0) tempi=tempi+2; i=i+1; /*明文轉(zhuǎn)換成密文*/void Express_chage_dark(char temp) int i; i=0; while(tempi!=0) tempi=tempi-2; i=i+1; /*整數(shù)輸入控制*/int Input_Integer() char str10; long n,i=0; scanf(%s,st

15、r); rewind(stdin); while(stri!=0) /對字符串的各個字符進行判斷,只是字符串結(jié)束 if(stri9) return -1; i+; n=atoi(str); /利用atoi函數(shù)將字符串str轉(zhuǎn)換成整型數(shù) return n; /返回輸入的正整數(shù)/*初始化用戶信息,讀取系統(tǒng)已有的用戶和用戶相應的日記*/userList Init_user() FILE *fp1; FILE *fp2; userList L=NULL; userNode *p; DiaryNode *s; if (fp1=fopen(Userlist,r+)=NULL) return L; whil

16、e(!feof(fp1) p=(userNode *)malloc(sizeof(userNode); if(fread(p,sizeof(userNode),1,fp1)!=1) break; p-firstedge=NULL; /讀取系統(tǒng)已有的用戶信息 p-next=L; L=p; chdir(p-user_name); /把相應用戶目錄作為當前工作目錄 if(fp2=fopen(dairylist,r+)=NULL) chdir(.); continue; else while(!feof(fp2) s=(DiaryNode *)malloc(sizeof(DiaryNode); /讀取

17、系統(tǒng)相應用戶的相應日記信息 if(fread(s,sizeof(DiaryNode),1,fp2)!=1) break; s-next=L-firstedge; L-firstedge=s; chdir(.); /把父目錄作為當前工作目錄 fclose(fp2); fclose(fp1); return(L); /*主菜單*/void main_meno(userList L) char choice;system(cls); do printf(nttPersonal Diary System(v1.0)0) /當不是第一個輸入刪除鍵時 ,進行的操作 rewind(stdin); print

18、f(b); printf( ); printf(bb); i-; continue; else if(tempi!=b&i=0) /當不是輸入刪除鍵時,輸出*號 printf(*); i=i+1; tempi=0; /*讀日記操作*/ void Read_dairy(char dairy_name) FILE *fp; char temp200; int i=0; fp=fopen(dairy_name,r); printf(ntThe content of diary is as following:ntt); while(feof(fp)=0) fscanf(fp,%c,&tempi);

19、i+; tempi=0; Dark_chage_express(temp); printf(%sn,temp); fclose(fp);/*修改用戶密碼*操作*/void Rejigger_user_password(userNode *H,userList L) char temp120; /用于保存原有的密碼 ,設計這個有利于密碼的更有效率的保存 char temp220; /用于保存第一次輸入的密碼 char temp320; /用于保存第二次輸入的密碼 char flag; strcpy(temp1,H-password); Dark_chage_express(temp1); pri

20、ntf(nntYour password is tt%s,temp1); printf(nn-?- Please input the password:n- ); Password_input(temp2); printf(n-?- Please input the password againn- ); Password_input(temp3); while(strcmp(temp2,temp3)!=0) /兩二次輸入的密碼一樣 printf(n-!- THE PASSWORDS IS NOT THE SAME!n); printf(nn-?- Please input the passw

21、ord:n- ); Password_input(temp2); printf(n-?- Please input the password againn- ); Password_input(temp3); Express_chage_dark(temp2); strcpy(H-password,temp2); printf(nnttPassword modifying ,please wait.); Sleep(1); Save_user(L); /系統(tǒng)休眠5秒 printf(nntt#Password has been changed!#nnt); system(pause); /*保存

22、相應用戶日記信息*/void Save_dairy(userNode *H) FILE *fp; DiaryNode *p; chdir(H-user_name); if(fp=fopen(dairylist,w)=NULL) printf(-!- CAN NOT OPEN THE FILE!n); system(PAUSE); return; p=H-firstedge; while(p!=NULL) fwrite(p,sizeof(DiaryNode),1,fp); p=p-next; chdir(.); fclose(fp); /*保存全部用戶信息*/void Save_user(use

23、rList L) FILE *fp; userNode *p; fp=fopen(Userlist,w); p=L; while(p!=NULL) fwrite(p,sizeof(userNode),1,fp); p=p-next; fclose(fp); /*查找是否有同名日記操作*/int Search_dairy(userNode *H,char temp) DiaryNode *p; p=H-firstedge; while(p!=NULL&strcmp(p-title,temp)!=0) p=p-next; if(p!=NULL) return 0; else return 1; /

24、*申請新用戶操作*/userList User_apply(userList L) char temp120; char temp220; int i; char flag; userNode *p; userNode *s; rewind(stdin); s=(userNode *)malloc(sizeof(userNode); system(cls); printf(nttt|n); printf(ttt|tRegistert|n); printf(ttt|n); printf(ntUser list:n); p=L; while(p!=NULL) printf(ttt%sn,p-use

25、r_name); p=p-next; /輸出系統(tǒng)已存在的用戶名,以讓用戶申請新用戶時,有個注意,不申請重復的用戶名 p=L; printf(nn-?- Please input a new name:n- ); scanf(%s,s-user_name); rewind(stdin); while(p!=NULL&strcmp(p-user_name,s-user_name)!=0) p=p-next; /判斷有沒有重復的用戶名 while(p!=NULL) printf(n-!- THE NAME IS EXIST!n); printf(n-?- Continue to register?(

26、Y or N)n- ); scanf(%c,&flag); if (flag=N|flag=n)free(s); return L; printf(n-?- Please input the name:n- ); scanf(%s,s-user_name); rewind(stdin); p=L; while(p!=NULL&strcmp(p-user_name,s-user_name)!=0) p=p-next; printf(nttt#The name can be used.#n); printf(n-?- Please input the password:n- ); Password

27、_input(temp1); printf(n-?- Please input the password again:n- ); Password_input(temp2); while(strcmp(temp1,temp2)!=0) printf(n-!- THE PASSWORDS IS NOT THE SAME!n); printf(n-?- Please input the password:n- ); Password_input(temp1); printf(n-?- Please input the password again:n- ); Password_input(temp

28、2); strcpy(s-password,temp1); s-firstedge=NULL; s-count=0; /申請好用戶,進行相應的操作 mkdir(s-user_name); /生成相應用戶對應的文件夾,文件夾里用來存儲相應用戶的相應日記 Express_chage_dark(s-password); /進行密碼家秘密 s-next=L; L=s; Save_user(L); /每添加一個用戶時,都要進行存儲用戶信息的保存 printf(nttRegistering please wait.); Sleep(2000); printf(nntt#Congratulations on

29、 your application is successful#nnt); system(pause); return(L); /*相應用戶登錄后的操作*/void User_Operate(userNode *H,userList L) char choice; DiaryNode *p; int i; system(cls); do printf(tt %s ,Welcome to the systemuser_name); printf(t|n); printf(t| 1.New 2.View 3.Delete 4.Modify password t|n); printf(t|n); p

30、rintf(ntDiary list:n); p=H-firstedge; printf(ntt|n); printf(tt|tNO.t themettimet |n); p=H-firstedge; i=1; while(p!=NULL) printf(tt|t%dt %st%st|n,i,p-title,p-date); p=p-next; /輸出相應用戶的日記名 i+; printf(tt|n); printf(nn-?- Please choose an item(Esc for qiut):n- ); choice=getche(); if (choice=Esc) return;

31、switch(choice) case 1: Write_dairy(H,L);break; /寫日記 case 2: Consult_dairy_meno(H);break; /查閱日記 case 3: Delete_dairy(H,L);break; /刪除日記 case 4: Rejigger_user_password(H,L);break; /修改用戶 system(cls); while(1); /*用戶登錄操作*/void User_Login(userList L) char temp20; char flag; int i,j,count; userNode *p; Diar

32、yNode *s; p=L; system(cls); printf(nttt|n); printf(ttt|tLogintt|n); printf(ttt|n); printf(ntUser list:n); printf(tt|n); printf(tt|tNO.t namett|n); count=1; while(p!=NULL) printf(tt|t%dt %stt|n,count,p-user_name); p=p-next; count+; /顯示系統(tǒng)全部的用戶信息,供用戶選擇登入 printf(tt|n); count-; printf(nn-?- Choose a numb

33、er:n- ); i=Input_Integer(); while(icount|i=-1) printf(nn-!- IUPUT ERROR); printf(n-?- continue to login?(Y or N)n- ); scanf(%c,&flag); if(flag=N|flag=n) return; printf(nn-?- choose a number:n- ); scanf(%d,&i); j=1; p=L; while(jnext; printf(n-$- You has choosen:tt%s,p-user_name); printf(n-?- Iuput th

34、e password:n- ); Password_input(temp); /輸入密碼 Express_chage_dark(temp); /明碼轉(zhuǎn)化為暗碼,以跟以保存的用戶密碼比較 while(strcmp(p-password,temp)!=0) printf(n-!- WRONG PASSWORD!n); printf(n-?- Continue to input?(Y or N)n- ); scanf(%c,&flag); if (flag=N|flag=n) return; printf(n-?- Input the password:n- ); Password_input(temp); Express_chage_dark(temp); printf(nntttLogining please wait.); Sleep(2000); system(cls); User_Operate(p,L); /用戶登入后,進行用戶操作 /*寫日記操作*/ void Write_dairy(userNode *H,userList L) char choi

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論