C语言 日记管理系统Word文件下载.docx
- 文档编号:4905455
- 上传时间:2023-05-04
- 格式:DOCX
- 页数:28
- 大小:19.90KB
C语言 日记管理系统Word文件下载.docx
《C语言 日记管理系统Word文件下载.docx》由会员分享,可在线阅读,更多相关《C语言 日记管理系统Word文件下载.docx(28页珍藏版)》请在冰点文库上搜索。
Diary*Init_Diary(Diary*D1);
voidInitial_Tag(Diary*D1,inttag);
User*Init_User(User*U1);
intOpen_Diary(Diary*D1);
Diary*Open_DiaryFile(Diary*D1,charFileName[]);
intOpen_File(charFileName[]);
intPrintf_DiaryList(Diary*D1);
voidPrint_Menu1(int*choose1);
voidPrint_Menu2(int*choose2);
voidPrint_Menu3(int*choose3);
intPrintf_users(User*U1);
intSave_Diary(Diary*D1);
intSave_Users_info(User*U1);
intSearch_Diary(Diary*D1);
Diary*Search_order(Diary*D1);
Diary*Filter_word(Diary*D1,charcmpword[],intn);
User*User_Login(User*U1);
intWrite_Diary(Diary*D1);
/*4**********************创建用户链表*********************/
intCreate_NewUser(User*U1)
intflag=0;
charpassword2[10];
User*s,*temp;
Diary*D2=NULL;
D2=Init_Diary(D2);
do
{
s=(User*)malloc(sizeof(User));
if(s==NULL)
{
printf("
用户创建失败"
);
return0;
}
\n请输入用户名:
"
scanf("
%s"
&
s->
username);
temp=Find_User(U1,s->
if(temp==NULL)
\n请输入6位密码:
Enter_Password(s->
password);
\n请确认密码:
Enter_Password(password2);
if(strcmp(s->
password,password2)!
=0)
\n密码确认错误\n\n"
}while(strcmp(s->
=0);
s->
diarys_list=D2;
nextu=U1->
nextu;
U1->
nextu=s;
flag=0;
Save_Users_info(U1);
\n用户创建成功!
\n"
else
{printf("
\n\n※※※对不起该用户名已存在※※※\n"
\n是否继续创建用户:
1/0"
%d"
flag);
}while(flag);
return1;
}
/*5****************初始化用户表**********************/
User*Init_User(User*U1)
U1=(User*)malloc(sizeof(User));
if(U1!
=NULL)
U1->
nextu=NULL;
returnU1;
else
returnNULL;
/*6*******************初始化日记表*******************/
Diary*Init_Diary(Diary*D1)
D1=(Diary*)malloc(sizeof(Diary));
if(D1!
D1->
nextd=NULL;
returnD1;
/*7**********将所有日记记录的标记tag值置为0或-1*************/
voidInitial_Tag(Diary*D1,inttag)
Diary*q;
q=D1->
nextd;
while(q!
q->
tag=tag;
q=q->
}
/*8***********************导入用户信息*******************/
intOpen_Users_info(User*U1)
FILE*fp;
User*U2=NULL,*U3=NULL;
Diary*D1=NULL,*D2=NULL;
charfilepn[20],tempstr[80];
/*用来存放文件保存路径以及文件名*/
strcpy(filepn,"
Users_info.txt"
if((fp=fopen(filepn,"
r"
))==NULL)//只读
※※不能打开文件※※\n"
fscanf(fp,"
%s\n"
tempstr);
//文本文件格式化输入
while(strcmp(tempstr,"
User:
"
)==0&
&
(!
feof(fp)))//到了文件末尾,函数值为非真
U2=(User*)malloc(sizeof(User));
if(U2==NULL)
※※用户空间申请失败※※\n"
用户名:
%20s\n"
U2->
密码:
%80s"
D1=Init_Diary(D1);
U2->
diarys_list=D1;
Diary:
feof(fp)))
D2=(Diary*)malloc(sizeof(Diary));
if(D2==NULL)
日记空间申请失败\n"
日期:
%s\n"
D2->
date);
关键字:
keyword);
标题:
title);
日记内容:
\n%s\n\n"
content);
D2->
tag=0;
nextd=D1->
D1->
nextd=D2;
}
//U1后插入
nextu=U2;
\n\n"
fclose(fp);
/*9********************显示用户列表**********************/
intPrintf_users(User*U1)
intcount=0;
User*p;
p=U1;
\n\n用户信息列表如下:
if(U1->
nextu==NULL)
\n没有用户信息\n"
while(p->
nextu!
p=p->
count++;
第%d个用户用户名:
count,p->
/*10**************************登录个人用户************************/
User*User_Login(User*U1)//登录成功返回改用户的日记链表指针
inti=0;
User*s=NULL,*tempU=NULL;
Printf_users(U1);
s=Init_User(s);
tempU=Init_User(tempU);
tempU=Find_User(U1,s->
if(tempU==NULL)
\n该用户不存在\n"
getch();
请输入密码:
rewind(stdin);
if(strcmp(tempU->
password,s->
password)==0)
returntempU;
\n密码错误\n"
/*11**********************获取登录口令********************/
intEnter_Password(charpassword[])
charpassword1[10];
inti;
for(i=0;
i<
=5;
i++)
password1[i]=getch();
password[i]=password1[i];
password1[i]='
*'
;
%c"
password1[i]);
password[i]='
\0'
/*12*********************查找用户********************/
User*Find_User(User*U1,charusername[])
User*q;
q=U1->
=NULL&
strcmp(q->
username,username)!
q=q->
if(q!
returnq;
/*13***********************保存用户信息*******************/
intSave_Users_info(User*U1)
Diary*D1;
charfilepn[20];
/*用来存放文件保存路径以及文件名*/
w+"
))==NULL)
printf("
不能打开文件!
while(U1->
fprintf(fp,"
U1=U1->
/*下移一个结点*/
%s\n密码:
U1->
username,U1->
D1=U1->
diarys_list;
while(D1->
nextd!
D1=D1->
日期:
%s\n关键字:
D1->
date,D1->
标题:
日记内容:
\n%s\n"
/*14**************打开普通文本文件*******************/
intOpen_File(charFileName[])
fp=fopen(FileName,"
//以只读的方式打开文件,将文件指针赋给fp
if(fp==NULL)
printf("
\n※※无法打开帮助文件※※"
while(feof(fp)==0)//将文件中的字符读入
fgetc(fp));
/*15**********************写新的日记*************************/
intWrite_Diary(Diary*D1)
inttemp;
Diary*p=NULL;
p=Init_Diary(p);
p=(Diary*)malloc(sizeof(Diary));
\n\n请输入日期(2012-12-12):
p->
\n请输入标题:
\n请开始写日记:
\n\n"
\n请为该日记写关键字:
p->
nextd=p;
\n━━━━━━━━━━━━━━━━━━━━━━━━━━\n"
是否要以文件方式保存日记?
1→是0→否"
temp);
if(temp==1)
Save_Diary(p);
/*16*********************日记保存***********************/
intSave_Diary(Diary*D1)
{
charFileName[40],postfix[6]="
.txt\0"
请输入文件路径及文件名:
FileName);
if((fp=fopen(FileName,"
打开文件失败!
正文如下:
\n%s\n"
日记文件保存成功!
/*17*******************打开并导入日记文件************************/
Diary*Open_DiaryFile(Diary*D1,charFileName[])
※※文件打开失败※※"
p=(Diary*)malloc(sizeof(Diary));
if(p==NULL)
{
printf("
※※日记创建失败※※"
}
fscanf(fp,"
p->
fscanf(fp,"
p->
fclose(fp);
returnp;
/*18**********************日记操作*************************/
intDiary_Operation(User*U2,Diary*D1)
chartempch='
y'
intchoose2;
charFileName[40];
while(tempch=='
Y'
||tempch=='
)
system("
cls"
Print_Menu2(&
choose2);
switch(choose2)
case0:
return0;
case1:
{
Write_Diary(D1);
}break;
case2:
{
printf("
\n请输入文件路径及文件名:
p=Open_DiaryFile(D1,FileName);
if(p!
Open_Diary(p);
}break;
case3:
if(Search_Diary(D1)==1)
tempch='
//打开帮助文件
case4:
n'
/*19************************进入菜单并选择操作************************/
voidPrint_Menu1(int*choose1)
\n☆用户管理☆\n"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n"
┃1.用户登录2.注册用户3.保存当前信息4.退出程序┃\n"
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n"
\n请选择操作:
choose1);
/*清空键盘缓冲区里的无用字符*/
/*20*******************进入日记菜单并选择操作*********************/
voidPrint_Menu2(int*choose2)
\n☆日记操作☆\n"
┃1.写日记2.导入日记3.查阅与删除4.返回上层┃\n"
choose2);
/*21*******************进入日记查阅菜单并选择操作********************/
voidPrint_Menu3(int*choose3)
\n☆日记查阅与删除☆\n"
┏━━━━━━━━━━━━━━━━━━━
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C语言 日记管理系统 语言 日记 管理 系统
![提示](https://static.bingdoc.com/images/bang_tan.gif)