2 新增聯絡人和退出通訊錄

2021-10-25 15:49:14 字數 1301 閱讀 5605

#include

//string標頭檔案

#include

using

namespace std;

//選單輸出,展示功能

void

showmenu()

//聯絡人資訊包括:姓名、性別、年齡、聯絡**、家庭住址

//設計如下:

//聯絡人結構體

struct person

;//設計通訊錄結構體

#define max 1000

//最大人數暫定為1000,可隨時更改

//通訊錄結構體

struct addressbooks

;//1.新增聯絡人

void

addperson

(addressbooks* abs)

else

cout <<

"輸入有誤,請重新輸入!"

<< endl;

}//年齡

cout <<

"請輸入年齡:"

<< endl;

int age =0;

while

(true

)else

cout <<

"您輸入的年齡不符合實際哦,請重新輸入 !"

<< endl;

}//**

cout <<

<< endl;

string phone;

cin >> phone;

abs-

>personarray[abs-

>m_size]

.m_phone = phone;

//家庭住址

cout <<

"請輸入您的家庭住址:"

<< endl;

string address;

cin >> address;

abs-

>personarray[abs-

>m_size]

.m_addr = address;

//更新通訊錄人數

abs-

>m_size++

; cout <<

"恭喜您,新增成功!!!"

<< endl;

system

("pause");

//請按任意鍵繼續

system

("cls");

//清屏操作}}

intmain()

}system

("pause");

return0;

}

訪問通訊錄中的聯絡人和新增聯絡人

1.在 androidmanifest.xml 中獲取通訊錄的讀寫功能 2.由於本 寫的是測試 因此也要在 androidmanifest.xml中加入測試啟動功能 3.獲取聯絡人資訊的函式constact public void constact throws exception phones.c...

Android讀取通訊錄聯絡人

cursor phonenumbercursor string phoneprojection phonenumbercursor contentresolver.query contactscontract.commondatakinds phone content uri,phoneprojec...

android讀取通訊錄聯絡人問題

string cols cursor cursor getcontentresolver query contactscontract.commondatakinds.phone.content uri,cols,null,null,null for int i 0 i cursor.getcoun...