项目的主要目标是开发一个面向个人的通讯录信息管理系统。它能实现个人对通讯录信息的处理,亦即对联系人和联系人群组信息的处理,比如显示、添加、删除、查询、修改等操作。项目具体的功能要求是:通讯信息以文本或二进制的形式存储在文件中,联系人可根据用户需求分为若干群组,每个群组可以使用不同文件,要求能添加、删除或修改联系人记录(姓名,手机,家电,邮箱,群组等),在修改或删除之前需要用户进一步确认,确认无误后再进行操作,一个联系人仅可以存在一个群组之中,删除联系人信息可以仅删除一项也可删除整个联系人信息。还可以添加、删除联系人群组或对群组改名,在删除群组后,该群组中的联系人自动设为无群组的联系人,通讯录按联系人姓名排序。增加查询功能,查询时只输入姓名的首字母,所有符合这一条件的电话资料均在屏幕上显示。
如果对编程方面有兴趣的可以加群:590750544,一起学习交流。群内有更多学习资料、软件、视频,免费课......
源码仅供参考:
// 电话目录系统
#include<iostream .h>
#include<fstream .h>
#include<iomanip .h>
#include<string .h>
#include<stdlib .h>
#include<conio .h>
#include<stdio .h>
#include<iomanip .h>
#include<graphics .h>
#include<dos .h>
class stud
{public:
char name[20];
char address[20];
unsigned int ph_no;
void get(void);
void show(void);
void modify(void);
};
void stud::get(void)
{
int i=0;
cout< <"\n Enter name -> ";
cin.get(name[i]);
while(name[i]!='\n')
{
i=i+1;
cin.get(name[i]);
}cin.getline(name,20,'\n');
cout< <" Enter address-> ";
cin.getline(address,20,'\n');
fflush(stdin);
cout< <" Enter ph_no\t-> \t";
cin>>ph_no;
fflush(stdin);
}
void stud::show(void)
{
cout< <"\n";
cout<<" NAME :"<<"\t"<<name<<"\n";
cout<<" ADDRESS :"<<"\t"<<address<<"\n";
cout<<" Ph_No :"<<"\t"<<ph_no<<"\n";
}
void main()
{
int gdriver = DETECT, gmode, errorcode;
int x,y;
int midx,midy;
/* 初始化图形和局部变量 */
initgraph(&gdriver, &gmode, "");
/* 读取初始化结果 */
errorcode = graphresult();
if (errorcode != grOk) /* 发生了一个错误 */
{printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* 终止与错误代码*/
closegraph();
}
y:
char*pass="RPV";
char*ppass;
gotoxy(25,8);
int size=7;
settextstyle(7,0,size);
setbkcolor(BLUE);
setcolor(WHITE);
outtextxy(180,50,"WELCOME" );
setcolor(WHITE);
outtextxy(250,200,"TO");
settextstyle(8,0,5);
setfillstyle(1,DARKGRAY);
setcolor(WHITE);
outtextxy(60,350,"\n\nTELEPHONE DIRECTORY");
getch();
clearviewport();
settextstyle(3,0,4);
settextstyle(7,0,4);
getch();
clearviewport();
g:
ppass=getpass("ENTER THE PASSWORD::");
if(strcmpi(pass,ppass)!=0)
{cout<<"\n\t\t\tIncorrect password";
cout<<"\n\t\t\tTry again";
getchar();
goto g;
}else
{
stud s;
char name[20];
char name1[20];
int ch;
clrscr();
setbkcolor(BLUE);
setcolor(YELLOW);
closegraph();
z:
cout<<"\n\n\n\n\n\n\n\n\n";
initgraph(&gdriver, &gmode,"c:\\tc\\bgi");
setcolor(BLUE);
rectangle(60,10,600,400);
setfillstyle(1,YELLOW);
bar(61,11,599,399);
outtextxy(200,30," HELP -> PRESS ANY KEY 1 TO 6 " );
settextstyle(TRIPLEX_FONT ,HORIZ_DIR,4);
outtextxy(220,50,"\n\n1. TO ADD " );
setcolor(BLUE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(220,100,"\n\n2. TO SHOW " );
setcolor(BLUE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(220,150,"\n\n3. TO SEARCH " );
setcolor(BLUE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(220,200,"4.\n\n TO MODIFY " );
setcolor(BLUE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(220,250,"\n\n\n5. TO DELETE " );
setcolor(BLUE);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(220,300,"\n\n\n6. TO EXIT " );
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(220,350," Enter the choice ->");
gotoxy(62,23);
cin>>ch;
switch(ch)
{
case 1: //终止与错误代码
{
clrscr();
fstream f;
f.open("rec",ios::in|ios::out|ios::ate|ios::app|ios::binary);
char ans;
s.get();
f.write((char *)&s,sizeof(s));
clrscr();
outtextxy(250,360, " Do you want to continue:- ");
ans=getche();
if(ans=='Y' || ans=='y'){goto z;}
f.close();
break;
}
case 2: // 将显示该文件的所有内容
{
clrscr();
cout< <"\n\n";
fstream f;
f.open("rec",ios::in|ios::out|ios::ate|ios::app|ios::binary);
f.seekg(0);
int ctr=0;
while(f.read((char *)&s,sizeof(s)) )
{
ctr=ctr+1;
if(ctr==8) {getchar(); clrscr();ctr=0;}
s.show();
if(f.eof()==1)
{break;}
}
f.close();
outtextxy(240,350, " Do you want to continue :-");
char ans;
ans=getche();
if(ans=='y'|| ans=='Y'){
closegraph();
goto z;}else{exit(1);}
}
case 3: // 搜索{
gotoxy(60,25);
clearviewport();
rectangle(10,10,630,470);
setbkcolor(DARKGRAY);
textbackground(3);
textcolor(5);
clrscr();
char ans;
ifstream f;
stud s;
char name[20];
char address[20];
unsigned int ph_no;
f.open("rec",ios::in|ios::binary);
cout<<"\n\n\n Enter name whose record to be search :";
cin>>name;
do
{
f.read((char *)&s,sizeof(s));
if(f.eof()==1) {break;}
if(strcmpi(s.name,name)==0)
{
cout< <"\n Name :"<<s.name;
cout<<"\n address :"<<s.address;
cout<<"\n phone_no :"<<s.ph_no;
getchar();}}while(f);
f.close();
settextstyle(7,0,1);
outtextxy(250,410,"Do You Want To Continue:");
ans=getchar();
if(ans=='Y'||ans=='y')
goto z;
else
{
closegraph();
break;
}
case 4: //对改性
{
clrscr();
char ans;
fstream f; stud s;
char name[20]; char address[20]; unsigned int ph_no;
f.open("rec",ios::in|ios::binary);
cout<<"\n\n\n Enter person ph_no whose record to be changed :";
cin>>ph_no;
do
{
f.read((char *)&s,sizeof(s));
if(f.eof()==1) {break;}
if(s.ph_no==ph_no)
{
cout< <"\n Current Name :"<<s.name;
cout<<"\n Current Address :"<<s.address;
cout<<"\n Current Phone No :"<<s.ph_no;
getchar();
cout<<"\n Enter the new name :";
cin>>name;
cout< <"\n Enter the city :";
cin>>address;
cout< <"\n Enter new ph_no :";
cin>>ph_no;
strcpy(s.name,name);
strcpy(s.address,address);
s.ph_no=ph_no;
int l=f.tellg();
f.close();
f.open("rec",ios::out|ios::binary|ios::ate);
f.seekg(l-sizeof(s));
f.write((char *)&s,sizeof(s));
}
}while(f);
f.close();
outtextxy(290,360, " Do you want to continue :-");
ans=getche();
if(ans=='Y'||ans=='y')
{goto z;}
break;
}
case 5: //负责删除记录
{
clrscr();
char name[20];
stud s;
ifstream fin;
fstream fout;
fin.open("rec",ios::in|ios::binary);
fout.open("va",ios::app|ios::binary);
cout< <"\n \t\t\t DELETING :-";
int i;
fflush(stdin);
cout<<"\n\n Enter the name :- ";
cin.get(name[i]);
while(name[i]!='\n')
{
i=i+1;
cin.get(name[i]);
}
fflush(stdin);
fflush(stdout);
cin.getline(name,20,'\n');
while(fin)
{
fin.read((char *)&s,sizeof (s));
if(strcmp(s.name,name)==0)
{fout.read((char *)&s,sizeof(s));
}
else
{
if(fin.eof()==1) {break;}
fout.write((char *)&s,sizeof(s));
}
}
fin.close();
fout.close();
system("del rec");
system("ren va rec");
cout<<"\n Enter is get Deleted:-";
getchar();
char ans;
outtextxy(240,340, " Do you want to continue:- ");
ans=getche();
if (ans=='y' || ans=='Y')
{goto z;}
else
if (ans=='n' || ans=='N')
{getchar();
exit(1);
}
}
case 6:
{
clearviewport();
outtextxy(250,360,"THE END OF THE PROJECT:-");
outtextxy(260,390,"\n \n\n\n\n PLEASE PRESS ENTER");
getchar();
closegraph();
exit(1);
}
default:
goto z;
}
}
}}
效果图:
以上是今天的内容一个大家常用的小工具,有什么问题的大家可以指出。
如果对编程方面有兴趣的可以加群:590750544,一起学习交流。
群内有更多学习资料、软件、视频,免费课......
本文暂时没有评论,来添加一个吧(●'◡'●)