如何用C语言编写一个简单的通讯录程序?
- 内容介绍
- 文章标签
- 相关推荐
本文共计2369个文字,预计阅读时间需要10分钟。
本文分享了一个使用C语言实现的简易通讯录程序的整体代码。程序功能描述如下:
1. 存储联系人的相关信息,包括姓名、性别、电话号码、备注等。
2.可输出通讯录的全部信息。
c
#include #include#define MAX_CONTACTS 100#define NAME_LEN 50#define PHONE_LEN 20
typedef struct { char name[NAME_LEN]; char gender[10]; char phone[PHONE_LEN]; char note[NAME_LEN];} Contact;
Contact contacts[MAX_CONTACTS];int contact_count=0;
void add_contact(const char* name, const char* gender, const char* phone, const char* note) { if (contact_count >=MAX_CONTACTS) { printf(通讯录已满,无法添加新联系人。
本文共计2369个文字,预计阅读时间需要10分钟。
本文分享了一个使用C语言实现的简易通讯录程序的整体代码。程序功能描述如下:
1. 存储联系人的相关信息,包括姓名、性别、电话号码、备注等。
2.可输出通讯录的全部信息。
c
#include #include#define MAX_CONTACTS 100#define NAME_LEN 50#define PHONE_LEN 20
typedef struct { char name[NAME_LEN]; char gender[10]; char phone[PHONE_LEN]; char note[NAME_LEN];} Contact;
Contact contacts[MAX_CONTACTS];int contact_count=0;
void add_contact(const char* name, const char* gender, const char* phone, const char* note) { if (contact_count >=MAX_CONTACTS) { printf(通讯录已满,无法添加新联系人。

