源代码:
#include \#include \#include \#include \#include \#define null 0
struct record {
char name[20]; char phone[20]; char adress[40]; char postcode[10]; char e_mail[30]; }student[500];
struct LinkList {
struct record US; struct LinkList *next; }a;
struct LinkList *head=null;
int num=0; FILE *fp;
int menu_select(); int adduser(); int list(); int search(); int display(); int add();
int listbyname(); int dele(); int save(); int exit();
void main() {
system(\ for(;;) {
switch(menu_select()) {
case 0:adduser();break; case 1:list();break; case 2:search();break; case 3:display();break; case 4:add();break;
case 5:listbyname();break; case 6:dele();break; case 7:save();break; case 8:exit(0); } } }
menu_select() {
char s[80]; int a;
printf(\ getch();
system(\
printf(\ printf(\ 0. 输入记录\\n\ printf(\ 1. 显示记录 \\n\ printf(\ 2. 按姓名查找\\n\ printf(\ 3. 按电话号码查找\\n\ printf(\ 4. 插入记录 \\n\ printf(\ 5. 按姓名排序\\n\ printf(\ 6. 删除记录\\n\ printf(\ 7. 记录保存文件\\n\ printf(\ 8. Quit\\n\
printf(\ do{
printf(\ Enter you choice(0~11):\ scanf(\ a=atoi(s); }
while (a<0||a>11); return a;
}
adduser() {
printf(\请输入用户信息 ****************\\n\ printf(\输入姓名:\
scanf(\ printf(\输入电话号码:\
scanf(\ printf(\输入地址:\
scanf(\ printf(\输入邮编:\
scanf(\ printf(\输入e-mail:\
scanf(\ num++;
printf(\是否继续添加?(Y/N):\ if (getch()=='y') adduser(); return(0); }
list() {
int i;
system(\ if(num!=0) {
printf(\以下为通讯录所有信息************\ for (i=0;i printf(\姓名: %s\ printf(\电话: %s\ printf(\地址: %s\ printf(\邮编: %s\ printf(\:%s\ printf(\ if (i+1 printf(\ system(\ } } printf(\ } else printf(\通讯录中无任何纪录\ printf(\按任意键返回主菜单:\ getch(); return(0); } search() { int mark=0; int i; int a=0; printf(\按姓名查找 *******************\ char name[20]; printf(\请输入姓名:\ scanf(\ for(i=a;i if (strcmp(student[i].name,name)==0) { printf(\以下是您查找的用户信息 ***********\ printf(\姓名: %s\ printf(\电话: %s\ printf(\地址: %s\ printf(\:%s\ printf(\ mark++; if ((i+1) printf(\是否继续查找相同名字的用户信息:(y/n)\ if (getch()=='y') { a=i; continue; } else return(0); } else { printf(\按任意键返回主菜单\ getch(); return(0); } } } if(mark!=0) { printf(\没有相同姓名的用户纪录\ printf(\按任意键返回主菜单\ getch(); return(0); } else { printf(\没有相同姓名的用户纪录\ printf(\按任意键返回主菜单\ getch(); return(0); } } display() { int mark=0; int i; int a=0; printf(\按电话查找 ******************\ char phone[10]; printf(\请输入电话号码:\ scanf(\ for(i=0;i if (strcmp(student[i].phone,phone)==0) { printf(\以下是您查找的用户信息 **********\ printf(\姓名: %s\ printf(\电话: %s\ printf(\地址: %s\ printf(\:%s\ printf(\ printf(\按任意键返回主菜单:\ mark++; getch(); return(0); }