通訊錄第二版

2021-08-01 13:13:03 字數 2351 閱讀 2099

address_list.h

#pragma once

#include #include #include #include #define default_sz 10

#define default_increment 10

#define length

#define name_max 20

#define ***_max 5

#define tele_max 11

#define addr_max 30

typedef struct info

info;

typedef struct contact

contact;

void initmy_contact(contact *pcon);//初始化結構體

void check_capacity(contact *pcon);//檢測容量

void addcontact(contact *pcon);//新增聯絡人資訊

void delcontact(contact *pcon);//刪除指定聯絡人資訊

void searchcontact(contact *pcon);//查詢指定聯絡人資訊

void modifycontact(contact *pcon);//修改指定聯絡人資訊

void showcontact(contact *pcon);//顯示所有聯絡人資訊

void emptycontact(contact *pcon);//清空所有聯絡人

void sortcontact(contact *pcon);//以名字或年齡排序所有聯絡人

address_list.c

#define _crt_secure_no_warnings 1

#include "address_list.h"

void initmy_contact(contact *pcon)

void check_capacity(contact *pcon)

else

}}void addcontact(contact *pcon)

void delcontact(contact *pcon)

; if(pcon->num == 0)

printf("請輸入要刪除的人名:");

scanf("%s", name);

for(i=0; inum; i++) }

if(i == pcon->num)

for(j=i; jnum-1; j++)

pcon->num--;

printf("刪除成功\n");

}void searchcontact(contact *pcon)

; printf("請輸入你要找的人名:");

scanf("%s", &name);

for(i=0; inum; i++) }

printf("沒有你要找的人\n");

}void modifycontact(contact *pcon)

; printf("請輸入要修改的人名:");

scanf("%s", name);

for(i=0; inum; i++) }

printf("要修改的人不存在\n");

}void showcontact(contact *pcon)

printf("%15s %4s %5s %11s %10s\n",

"名字", "年齡", "性別", "**", "位址");

for(i=0; inum; i++) }

void sortcontact(contact *pcon)

; int input = 0;

if(pcon->num == 0)

printf("####1.按名字 2.按年齡####\n");

scanf("%d", &input);

switch(input)}}

printf("排序成功\n");

return;

} case 2:}}

printf("排序成功\n");

return;

} }}void emptycontact(contact *pcon)

test.c

#define _crt_secure_no_warnings 1

#include "address_list.h"

void menu()

enum option

;int main()

}while(input);

return 0;

}

簡易通訊錄(檔案版)

第二個模組便是我們的測試函式,測試函式便可以實現我們的選單列印,同時由我們接收不同的值便可以實現不同的操作,就是相應的方法的實現,這裡很明顯可以通過乙個switch語句來進行控制。第三個模組便是我們的方法實現的函式,將模組2裡定義的型別為通訊錄的位址傳到各個方法裡,這樣便可以實現對通訊錄的操作。in...

單鏈表通訊錄 通訊錄2 0

單鏈表通訊錄 通訊錄2.0 標頭檔案 ifndef address h define address h include include include define success 10000 define failure 10001 define true 10002 define false ...

C語言通訊錄(初級版)

這裡是乙個簡單的通訊錄,固定為1000容量,不能動態增長,不能寫入檔案。初級版本。define crt secure no warnings 1 include include int count 0 void menu typedef struct teldir dir dir stu 1000 ...