通讯录
完成以下功能的通讯录:
- 增加通讯录成员
- 删除通讯录成员
- 显示现有通讯录
- 修改某条通讯录成员(能模糊查找对应要修改的成员)
- 对现有通讯录进行排序(可选择关键字)
- 在通讯录中查找(可模糊查找)
- 从外部文件导入通讯录
- 保存通讯录到文件
代码
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct{
//数据结构体
char name[10];
char nickname[20];
char number[20];
char phone[15];
char card[10];
char location[20];
char address[20];
} person;
typedef struct one{
//链表结构体
person single;
struct one *next;
} list;
typedef struct abc{
//查找时的链表
list *ser ;
struct abc *next ;
}List;
list *Start,*End; //定义链表头和尾
int c[7]={
0,10,30,50,65,75,95}; //结构体位移量
void pause(){
//暂停
printf("按回车回到主菜单!");
fflush(stdin);
getchar();
return ;
}
void puttop(){
//打表头
printf("%-10s\t%-20s\t%-20s\t%-15s\t%-10s\t%-20s\t%-20s\n","姓名(10)","昵称(20)","生日(20)","电话号码(15)","寝室号(10)","籍贯(10)","E-mail地址(20)");
return ;
}
List *look(int b,char f[]){
//查找
List *head,*q;
list *p=Start->next;
head=q=(List *)malloc(sizeof(List));
head->next=(List *)malloc(sizeof(List));
q->next->next=NULL;
q->next->ser=Start;
while(p)
{
person a;
a=p->single;
char *g=a.name+c[b-1];
int flag=0;
int i=0,j=0;
for(;g[i];){
if(f[j]=='?') j++,i++ ;
else if(f[j]=='*') flag=1,j++;
else if(f[j]==g[i]) j++,i++;
else break;
while(flag&&g[i]){
if(f[j]==g[i]) flag=0,i++,j++;
else i++;
}
}
if(f[j]) q->next