通讯录管理系统C语言.docx

上传人:b****2 文档编号:2535503 上传时间:2023-05-03 格式:DOCX 页数:50 大小:403.35KB
下载 相关 举报
通讯录管理系统C语言.docx_第1页
第1页 / 共50页
通讯录管理系统C语言.docx_第2页
第2页 / 共50页
通讯录管理系统C语言.docx_第3页
第3页 / 共50页
通讯录管理系统C语言.docx_第4页
第4页 / 共50页
通讯录管理系统C语言.docx_第5页
第5页 / 共50页
通讯录管理系统C语言.docx_第6页
第6页 / 共50页
通讯录管理系统C语言.docx_第7页
第7页 / 共50页
通讯录管理系统C语言.docx_第8页
第8页 / 共50页
通讯录管理系统C语言.docx_第9页
第9页 / 共50页
通讯录管理系统C语言.docx_第10页
第10页 / 共50页
通讯录管理系统C语言.docx_第11页
第11页 / 共50页
通讯录管理系统C语言.docx_第12页
第12页 / 共50页
通讯录管理系统C语言.docx_第13页
第13页 / 共50页
通讯录管理系统C语言.docx_第14页
第14页 / 共50页
通讯录管理系统C语言.docx_第15页
第15页 / 共50页
通讯录管理系统C语言.docx_第16页
第16页 / 共50页
通讯录管理系统C语言.docx_第17页
第17页 / 共50页
通讯录管理系统C语言.docx_第18页
第18页 / 共50页
通讯录管理系统C语言.docx_第19页
第19页 / 共50页
通讯录管理系统C语言.docx_第20页
第20页 / 共50页
亲,该文档总共50页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

通讯录管理系统C语言.docx

《通讯录管理系统C语言.docx》由会员分享,可在线阅读,更多相关《通讯录管理系统C语言.docx(50页珍藏版)》请在冰点文库上搜索。

通讯录管理系统C语言.docx

通讯录管理系统C语言

通讯录管理系统

 

1.需求分析

随着通讯科技的发展,人们对通讯录的需求也非常紧迫。

在计算机还未普及之前通讯管理都是由联系人采用名片,笔录手工记帐的方式来操作的。

现在一般的通讯录管理都是采用计算机作为工具的实用的计算机通讯录管理程序来帮助人们进行更有效的通讯录信息管理。

在系统中创建通讯录std_table.txt进行后续操作

每条信息记录要求包含:

1.姓名

2.电话

3.性别

4.年龄

5.生日

6.寝室地址

系统功能包括:

1.创建或连续创建学生通讯录

2.显示全部学生通讯录信息

3.添加学生通讯录信息

4.修改学生通讯录信息

5.删除学生通讯录信息

6.查询学生通讯录信息

7.排序学生通讯录信息

8.退出

2.概要设计

根据需求分析中的描述,知道需要一个学生类型,由于基本数据类型无法实现将一个用户的信息绑定在一起,所以需要定义一个structstudent的链表

structstudent

{charname[15];

chartel[20];

charsex[15];

charage[3];

charbirth[20];

charaddress[40];

structstudent*next;

};

在这链表中,学生的姓名、电话、性别、年龄、生日、寝室地址全部使用char数组类型。

在此程序中使用多种函数,函数的参数全部使用局部变量,这样可以提高函数灵活调用的特性,使程序更加灵活。

structstudent*create(structstudent*head);//建立链表

structstudent*insert(structstudent*head,char*name,chartel[],charsex[],charage[],charbirth[],charaddress[]);//插入学生信息

voidprint(structstudent*head);//输出全部学生信息

voidsave_new(structstudent*head);//保存(new)

voidsave_new_plus(structstudent*head);//保存(new)_plus

voidsave_in(structstudent*head);//保存(in)

voidsave_in_sort(structstudent*head);//保存(sort)

voidnew_table();//新建通讯录

voidnew_table_plus();//新建通讯录_plus

voidadd_student();//追加学生信息

voidquery_student_all();//查询所有学生

voidupdate(structstudent*head);//把链表内信息写入文件

voidquery_student_name(structstudent*head);//按姓名查询指定学生

voidquery_student_tel(structstudent*head);//按电话查询指定学生

structstudent*delete_student_name(structstudent*head);//按姓名删除指定学生

structstudent*delete_student_tel(structstudent*head);//按电话删除指定学生

structstudent*modify_student_name(structstudent*head);//按姓名修改指定学生

structstudent*modify_student_tel(structstudent*head);//按电话修改指定学生

structstudent*sort_student_name(structstudent*head);//按姓名排序

structstudent*sort_student_tel(structstudent*head);//按电话排序

structstudent*insert_student_name(structstudent*head);//按姓名插入

structstudent*insert_student_tel(structstudent*head);//按电话插入

voidmain_select();//主菜单

voidquery_select();//查询菜单

voidadd_select();//添加菜单

voiddelete_select();//删除菜单

voidupdate_select();//更新菜单

3.详细设计

*********************************************************************

创建链表的主要过程函数:

1)建立链表structstudent*create(structstudent*head);

2)插入学生信息

structstudent*insert(structstudent*head,char*name,chartel[],charsex[],charage[],charbirth[],charaddress[]);

3)输出全部学生信息至窗口voidprint(structstudent*head);

4)把链表内信息写入文件voidupdate(structstudent*head);

*********************************************************************

新建学生通讯录信息和添加学生通讯录信息主要过程函数:

1)新建通讯录voidnew_table();

voidnew_table_plus();

2)追加学生信息voidadd_student();

3)保存voidsave_new(structstudent*head);

voidsave_new_plus(structstudent*head);

voidsave_in(structstudent*head);

voidsave_in_sort(structstudent*head);

*********************************************************************

查询学生通讯录信息主要过程函数:

1)查询所有学生voidquery_student_all();

2)指定查询(按姓名、按电话)

voidquery_student_name(structstudent*head);

voidquery_student_tel(structstudent*head);

*********************************************************************

删除学生通讯录信息主要过程函数:

1)指定删除(按姓名、按电话)

structstudent*delete_student_name(structstudent*head);

structstudent*delete_student_tel(structstudent*head);

2)保存到文件

*********************************************************************

修改学生通讯录信息主要过程函数:

1)指定修改(按姓名、按电话)

structstudent*modify_student_name(structstudent*head);

structstudent*modify_student_tel(structstudent*head);

2)保存到文件

*********************************************************************

排序学生通讯录信息主要过程函数:

1)指定排序(按姓名、按电话)

structstudent*sort_student_name(structstudent*head);

structstudent*sort_student_tel(structstudent*head);

2)保存到文件

*********************************************************************

插入学生通讯录信息主要过程函数:

1)指定插入(按姓名、按电话)

structstudent*insert_student_name(structstudent*head);

structstudent*insert_student_tel(structstudent*head);

2)保存到文件

*********************************************************************

菜单函数:

1)主菜单voidmain_select();

2)查询菜单voidquery_select();

3)添加菜单voidadd_select();

4)删除菜单voiddelete_select();

5)更新菜单voidupdate_select();

*********************************************************************

4.用户使用手册

4.1环境设置

1.在指定的目录下创建一个win32工程,如图1所示。

2.将所有的已经创建的扩展名为std_main文件和扩展名为.c文件添加到步骤1所创建的工程中对应的SourceFiles中。

如图2所示。

4.2操作步骤

0.编译扩展名为.c的文件,如果有编译错误,则根据提示修改,否则编译成功。

最后编译、连接和运行测试程序文件,如图3所示。

1.1在当前的Dos窗口中,输入1回车,进入查询学生通讯录菜单,显示如图1.1所示。

1.2在当前的Dos窗口中,输入被查询学生的名字,显示如图1.2所示。

(如有重名现象系统会全部显示)

1.3在当前的Dos窗口中,输入被查询学生的电话,显示如图1.3所示。

(如有重名现象系统会全部显示)

1.4在当前的Dos窗口中,输入3系统会显示全部学生信息,显示如图1.4所示。

1.5在查询中如果输入错误信息,系统将无法找到此学生,显示如图1.5所示。

1.6在当前的Dos窗口中,输入0则返回主菜单,显示如图1.6所示。

2.1在当前的Dos窗口中,输入2进入添加同学通讯录菜单,显示如图2.1所示。

2.2在当前Dos窗口中,输入1,进入新建通讯录,根据提示输入新建文件的地址,如果该文件已经存在,系统会提示是否覆盖原文件,如果该文件不存在,系统直接进入下一界面,如果选择N,系统将不覆盖原文件并且返回上级菜单,显示如图2.2所示。

2.3在当前Dos窗口中,根据提示一次输入学生姓名、电话、性别、年龄、生日、宿舍地址,单击回车系统询问是否保存信息,如果输入N系统返回上级菜单,输入Y进入下一界面,示如图2.3所示。

2.4在当前Dos窗口中,选择Y系统将进行新的一位学生信息的输入,选择N返回上级菜单,示如图2.4所示。

2.5在当前的Dos窗口中,输入2进入添加同学至原有文件,显示如图2.5所示。

2.6在当前Dos窗口中,根据提示一次输入学生姓名、电话、性别、年龄、生日、宿舍地址,单击回车系统询问是否保存信息,如果输入N系统返回上级菜单,输入Y进入提示,在提示中可以选择是继续添加、返回上级菜单,示如图2.6所示。

3.1在当前的Dos窗口中,输入3进入删除学生通讯录菜单,显示如图3.1所示。

3.2在当前的Dos窗口中,输入1进入按姓名删除学生,显示如图3.2所示。

3.3在当前Dos窗口中,输入查找的学生名字,系统会查找所有联系人,如有重名的联系人,系统会一次弹出询问是否删除此学生信息。

删除完毕后,系统给出提示是重新删除新的学生还是返回上级菜单,显示如图3.3所示。

3.4在当前Dos窗口中,输入查找的学生电话步骤与3.3相同,示如图3.4所示。

4.1在当前的Dos窗口中,输入4进入更新学生菜单,显示如图4.1所示。

4.2在当前的Dos窗口中,输入1进入按姓名修改,显示如图4.2所示。

4.3在当前Dos窗口中,输入查找的学生名字,系统会查找所有联系人,如有重名的联系人,系统会一次弹出询问是否修改此学生信息。

同意修改之后系统弹出学生信息修改选项菜单,显示如图4.3所示。

4.4如选择2进行对学生电话的修改,根据提示输入修改后的电话号码,单击回车,系统自动弹出修改选项卡,输入9确认,系统显示修改成功并提示是否同意保存修改。

当用户想放弃本次就该可以输入0取消,系统返回上级菜单,显示如图4.4所示。

(按电话修改也是一样的)

4.5在Dos窗口中输入3按姓名排序学生通讯录,系统会按学生的拼音名升序排列,如果输入4按电话排序学生通讯录,系统会按学生的电话升序排列,排序完成,系统给出“排序完成”字样,显示如图4.5所示。

4.6在Dos窗口中输入5按姓名插入学生通讯录(输入完成后名单按姓名排序),给出以下界面,根据提示进行操作。

如果输入6按电话插入学生通讯录(输入完成后名单按电话排序),显示如图4.6所示。

 

5.使用的主要技术

主要使用链表添加、插入、排序、读取、删除和文件读写技术

6.总结

在本次编程过程中,我先是参考类似的学生管理系统进行编程思路的梳理,搭建起程序大体的结构框架。

因为在此程序编写中要运用到链表和文件读写功能,这些功能先前从未学习和了解过,所以我到图书馆和网络进行相关内容的学习,并在此程序中逐步攻克实践。

程序在链表程序的基础上,增加查询功能,让程序的功能更加多样。

本通讯录管理程序仍然有不完善的地方,本程序是在CMD控制台里完成输入和输出的,如果能使用窗口界面进行操作会是一个很大的进步。

本程序是在一个.C文件中完成编写的,希望以后能够拆分成多个.C文件运行。

本程序在运行过程中没有释放使用的内存,希望以后有待改进。

相信在之后的学习和实践中能不断完善此通讯录管理程序的编写。

附录

程序代码:

#include

#include

#include

#include

#include

structstudent

{charname[15];

chartel[20];

charsex[15];

charage[3];

charbirth[20];

charaddress[40];

structstudent*next;

};

charurl[100];

structstudent*create(structstudent*head);//建立链表

structstudent*insert(structstudent*head,char*name,chartel[],charsex[],charage[],charbirth[],charaddress[]);//插入学生信息

voidprint(structstudent*head);//输出全部学生信息

voidsave_new(structstudent*head);//保存(new)

voidsave_new_plus(structstudent*head);//保存(new)_plus

voidsave_in(structstudent*head);//保存(in)

voidsave_in_sort(structstudent*head);//保存(sort)

voidnew_table();//新建通讯录

voidnew_table_plus();//新建通讯录_plus

voidadd_student();//追加学生信息

voidquery_student_all();//查询所有学生

voidupdate(structstudent*head);//把链表内信息写入文件

voidquery_student_name(structstudent*head);//按姓名查询指定学生

voidquery_student_tel(structstudent*head);//按电话查询指定学生

structstudent*delete_student_name(structstudent*head);//按姓名删除指定学生

structstudent*delete_student_tel(structstudent*head);//按电话删除指定学生

structstudent*modify_student_name(structstudent*head);//按姓名修改指定学生

structstudent*modify_student_tel(structstudent*head);//按电话修改指定学生

structstudent*sort_student_name(structstudent*head);//按姓名排序

structstudent*sort_student_tel(structstudent*head);//按电话排序

structstudent*insert_student_name(structstudent*head);//按姓名插入

structstudent*insert_student_tel(structstudent*head);//按电话插入

voidmain_select();//主菜单

voidquery_select();//查询菜单

voidadd_select();//添加菜单

voiddelete_select();//删除菜单

voidupdate_select();//更新菜单

structstudent*insert(structstudent*head,char*name,chartel[],charsex[],charage[],charbirth[],charaddress[])

{structstudent*p,*t;

t=head;

p=(structstudent*)malloc(sizeof(structstudent));

strcpy(p->name,name);

strcpy(p->tel,tel);

strcpy(p->sex,sex);

strcpy(p->age,age);

strcpy(p->birth,birth);

strcpy(p->address,address);

p->next=NULL;

if(t==NULL)

head=p;

else

{while(t->next!

=NULL)

{t=t->next;

}

t->next=p;

}

returnhead;

}

structstudent*create(structstudent*head)//建立链表

{charname[15];

chartel[20];

charsex[15];

charage[10];

charbirth[20];

charaddress[40];

FILE*fp;

if((fp=fopen("d:

//std_table.txt","r"))==NULL)

{

printf("\nopenerror!

!

\n");

getchar();

exit(0);

}

while(!

feof(fp))

{fscanf(fp,"%15s%10s%15s%10s%20s%40s",&name,tel,sex,age,birth,address);

head=insert(head,name,tel,sex,age,birth,address);

}

returnhead;

fclose(fp);

}

voidupdate(structstudent*head)

{structstudent*p;

FILE*fp;

p=head->next;

if((fp=fopen("d:

//std_table.txt","w"))==NULL)

{

printf("\nopenerror!

!

\n");

getchar();

exit(0);

}

while(p!

=NULL)

{

fprintf(fp,"%s%10s%10s%10s%15s%20s",p->name,p->tel,p->sex,p->age,p->birth,p->address);

fprintf(fp,"\n");

p=p->next;

}

fclose(fp);

}

voidsave_new(structstudent*head)

{structstudent*p;

charflag;

FILE*fp;

p=NULL;

if((fp=fopen(url,"wt"))==NULL)

{

printf("\nopenerror!

!

\n");

getchar();

exit(0);

}

p=head;

if(fprintf(fp,"\n%s%s%s%s%s%s",p->name,p->tel,p->sex,p->age,p->birth,p->address)==1)

printf("写入错误\n");

elseprintf("写入成功\n");

fclose(fp);

printf("是否继续添加学生通讯录Y:

继续添加/N:

返回上级菜单");

scanf("%*c%c",&flag);

if(flag=='Y'||flag=='y')

{new_table_plus();

}else{system("cls");add_select();}

}

voidsave_new_plus(structstudent*head)

{structstudent*p;

charflag;

FILE*fp;

p=NULL;

if((fp=fopen(url,"at+"))==NULL)

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 幼儿教育 > 育儿理论经验

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2