You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
#include
#include
#include<malloc.h>
using namespace std;
#define MAX 1000
void showMenu() {
cout << "1.添加联系人" << endl;
cout << "2.显示联系人" << endl;
cout << "3.删除联系人" << endl;
cout << "4.查找联系人" << endl;
cout << "5.修改联系人" << endl;
cout << "6.清空联系人" << endl;
cout << "0. 退出系统 " << endl;
}
//设计联系人结构体
struct Person
{
string m_Name;
int m_Sex;//性别:1男 2女
int m_Age;
string m_Phone;
string m_Addr;
};
//设计通讯录结构体
struct Addressbooks
{
struct Person personArray[MAX]; //通讯录中联系人的数组
int m_size; //通讯录中联系人个数
};
//添加联系人
void addPerson(Addressbooks *abs) {
//判断通讯录是否已经满了
if (abs->m_size == MAX) {
cout << "通讯录已经满了" << endl;
return;
}
else {
//添加联系人
string name;
cout << "输入需要添加的联系人的姓名:" << endl;
cin >> name;
abs->personArray[abs->m_size].m_Name = name;
// cin >> name;
![图片](https://user-images.githubusercontent.com/49153353/89118223-5907e180-d4d6-11ea-9b47-aca7b6cdfac1.png)
// abs->personArray[abs->m_size].m_Name = name;
}
}
//封装添加联系人函数
//测试添加联系人功能
int main() {
int select;
//main函数中创建通讯录
Addressbooks abs;
//struct Addressbooks *abs;
while (true) {
//菜单调用
showMenu();
//创建一个用户选择变量
cin >> select;
switch (select) {
case 1:
addPerson(&abs);
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 0:
cout << "欢迎下次使用" << endl;
system("pause");
return 0;
break;
default:
break;
}
}
system("pause");
return 0;
}
按1添加联系人时候就会出现异常:读取访问权限冲突
The text was updated successfully, but these errors were encountered: