用C/C++写一个电子名片管理系统
手机已成为生活中必不可少的,管理其中的联系人信息,包括常用的社交信息更是不可或缺的。下面是如何用 C/C++实现联系人信息的管理。
要包含的头文件
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <iostream>
#include<stdio.h>
#include <fstream>
using namespace std;
#define N 15 //最多储存人数
string classify[20];
首先定义联系人的结构体、根据需要定义结构体内容和声明所需要的功能函数
struct person //结构体定义个人信息
{
int number;
string Name;
string place;
string Phonenumber[3]; //每人最多存三个电话号码,用于实现一人多号
string QQ;
string Wechat;
string e_mile;
string blog;
string classify;
}per[N];
void meun();
void search();
void add();
void modify();
void delect();
void show();
void wr();
void save();
void definetype();
其次是菜单函数用来选择各种功能
void menu()
{
system("cls");
int n, w; //菜单选项
do
{
puts("\t\t****************通讯录界面******************");
puts("\t\t\t\t1.添加联系人");
puts("\t\t\t\t2.搜索联系人");
puts("\t\t\t\t3.修改资料");
puts("\t\t\t\t4.删除资料");
puts("\t\t\t\t5.查看全部联系人");
puts("\t\t\t\t6.进行分组");
puts("\t\t\t\t7.存储");
puts("\t\t\t\t8.退出");
puts("\t\t*******************************************\n");
cout << "选择功能:【】\b\b" << endl;
cin >> n;
if (n < 1 || n>8)
{
w = 1; getchar();
}
else w = 0;
} while (w == 1);
switch (n)
{
case 1:system("cls");add(); break; //查找
case 2:system("cls");search(); break; //增加
case 3:system("cls");modify(); break; //修改
case 4:system("cls");delect(); break; //删除
case 5:system("cls");show(); break; //展示所有联系人姓名、分组
case 6:system("cls");definetype(); break;
case 7:system("cls");save(); break;
case 8:system("cls");cout << "********************程序结束,谢谢使用********************";exit(0);
defult:cout << "输入正确数字" << endl;
}
};
下面是各个功能函数
void showone(int x, person per[])
{
cout << "姓名: " << per[x].Name << endl;
cout << "电话: " << per[x].Phonenumber[0] << " " << per[x].Phonenumber[1] << " " << per[x].Phonenumber[2] << endl;
cout << "博客: " << per[x].blog << endl;
cout << "类别: " << per[x].classify << endl;
cout << "邮箱: " << per[x].e_mile << endl;
cout << "QQ: " << per[x].QQ << endl;
cout <