通讯录管理软件c++编程

通讯录管理软件c++编程

ID:13310180

大小:61.50 KB

页数:10页

时间:2018-07-21

通讯录管理软件c++编程_第1页
通讯录管理软件c++编程_第2页
通讯录管理软件c++编程_第3页
通讯录管理软件c++编程_第4页
通讯录管理软件c++编程_第5页
资源描述:

《通讯录管理软件c++编程》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、#include#include#include#include#include//文本操作默认信息保存在工程文件夹下#defineN40//定义基本信息的长度intt;usingnamespacestd;charname[N];//全局变量定义charaddress[N];charphone[N];charcode[N];charemail[N];classhum{private:charname[N];//基础类的定义charaddress

2、[N];charphone[N];charcode[N];charemail[N];public:hum*next;hum(){}~hum(){}friendclassList;};classList:publichum//私有信息封装{private:hum*head,*tail;public:List();~List();voidCreatList();voidset(char*name=".",char*address=".",char*phone=".",char*code=".",char*email=".");voidDe

3、lete(intt);voidChange(char*name);voidFind(intx);voidfilecin();voidfileout();voidshowall();};List::List(){head=tail=NULL;}List::~List(){hum*p;if(head){p=head;head=head->next;deletep;}}voidList::set(char*name,char*address,char*phone,char*email,char*code)//文本导入时调用的构造函数{hum

4、*p=newhum;strcpy(p->name,name);strcpy(p->address,address);strcpy(p->phone,phone);strcpy(p->code,code);strcpy(p->email,email);p->next=NULL;if(head==NULL)head=p;elsetail->next=p;tail=p;}voidList::CreatList()//默认的构造函数{intflag=1;hum*p=newhum;strcpy(p->name,".");strcpy(p->ad

5、dress,".");strcpy(p->phone,".");strcpy(p->code,".");strcpy(p->email,".");getchar();cout<<"请输入学生姓名:";gets(name);if(strcmp(name,"")!=0)strcpy(p->name,name);cout<<"请输入家庭地址:";gets(address);if(strcmp(address,"")!=0)strcpy(p->address,address);cout<<"请输入联系电话:";gets(phone);if(s

6、trcmp(phone,"")!=0)strcpy(p->phone,phone);cout<<"请输入邮编:";gets(code);if(strcmp(code,"")!=0)strcpy(p->code,code);cout<<"请输入电子邮件:";gets(email);if(strcmp(email,"")!=0)strcpy(p->email,email);hum*q=head;while(q){//判断是否以存在相同的信息if(strcmp(q->name,name)==0&&strcmp(q->address,addr

7、ess)==0&&strcmp(q->phone,phone)==0&&strcmp(q->code,code)==0&&strcmp(q->email,email)==0){flag=0;cout<<"已存在相同信息!存入失败!";break;}q=q->next;}if(flag){ofstreamoutfile;outfile.open("cin.txt",ios::app);//将新数据添加的文本末尾if(!outfile)//调试期间怕出错添加的判断函数{cerr<<"Fileopenorcreateerror!"<

8、name<<""<address<<""<phone<<""<code<<""<email;outfile.close()

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。