毕业论文

当前位置: 毕业论文 > 范文 >

C语言通讯录设计及通讯录设计源代码(4)

时间:2021-03-10 12:36来源:辣文论文
{ char Name[10]; char Year[4]; char Sex[5]; char Tel[12]; char Address[30]; struct TXL *next; }character, *pcharacter, **ppcharacter; int count=0; pcharacter list=NULL; static pcharacter book; void ge

{   char Name[10];

char Year[4];

char Sex[5];

char Tel[12];

char Address[30];

struct TXL *next;

}character, *pcharacter, **ppcharacter;

int count=0;

pcharacter list=NULL;

static pcharacter book;

void getPeople(pcharacter);

void addPeople(ppcharacter);

pcharacter searchPeople(pcharacter,char query[]);

pcharacter updatePeople(pcharacter,char query[]);

void delPeople(ppcharacter,char query[]);

void displayCharacter(pcharacter);

void displaySingle(pcharacter);

void getPeople(pcharacter txl)

{

printf("请输入联系人姓名:\t");

scanf("%s", txl -> Name);

printf("请输入联系人年龄:\t");

scanf("%s", txl -> Year);

printf("请输入联系人性别:\t");

scanf("%s", txl -> Sex);

printf("请输入联系人电话:\t");

scanf("%s", txl -> Tel);

printf("请输入联系人住址:\t");

scanf("%s", txl -> Address);

}

void addPeople(ppcharacter txl)

{

pcharacter new;

if(list!=NULL)

{

new=list;

list=list->next;

count--;

}

else

{

new=(pcharacter)malloc(sizeof(character));

if(new==NULL)

{

printf("内存分配失败");

exit(1);

}

}

getPeople(new);

if(*txl==NULL)

{

*txl=new;

new->next=NULL;

}

else

{

book->next=new;

new ->next=NULL;

}

book = new;

}

pcharacter searchPeople(pcharacter txl,char query[])

{

pcharacter copy;

copy=txl;

while(copy!=NULL)

{

if(strcmp(copy->Name,query))

{

copy=copy->next;

}

else

{

printf("找到了联系人\n");

return copy;

}

}

return NULL;

}

pcharacter updatePeople(pcharacter txl,char query[])

{

char ch;

pcharacter copy;

copy=txl;

while(copy!=NULL)

{

if(strcmp(copy->Name,query))

{

copy=copy->next;

}

else

{

printf("您确定要修改%s的信息吗? (Y/N)\n",query);

do{

ch=getchar();

}

while(ch!='Y');

if(ch=='Y')

{

printf("请输入新的内容:\n");

printf("请输入联系人姓名:\t");

scanf("%s", copy -> Name);

printf("请输入联系人年龄:\t");

scanf("%s", copy-> Year);

printf("请输入联系人性别:\t");

scanf("%s", copy -> Sex);

printf("请输入联系人电话:\t");

scanf("%s", copy -> Tel);

printf("请输入联系人住址:\t"); C语言通讯录设计及通讯录设计源代码(4):http://www.751com.cn/fanwen/lunwen_71172.html

------分隔线----------------------------
推荐内容