#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct message
{
char NAME[10];
char GENDER[10];
char TEL[10];
char CITY[10];
char EIP[10];
}message;
struct LNode{
message data;
struct LNode *next;
};
typedef struct LNode List;
void FindList(List head, charNAME)
{
List *p=head;
while (p != NULL)
if(strcmp(p->data.NAME,*NAME)==0);
{
printf ("好友信息:NAME:%s GENDER:%s TEL:%s CITY:%s EIP:%s\n");
return;
}
p=p->next;
{
printf ("通讯录中没有此人的信息!\n");
}
}
void DeleteList(List head,char NAME) {
if (head == NULL) {
printf("单链表为空,删除操作无效!\n");
}
List cp = head;
List ap = NULL;
while (cp != NULL) {
if (strcmp(NAME, cp->data.NAME)) break;
else {
ap = cp;
cp = cp->next;
}
}
if (cp == NULL) {
printf("通讯录中没有此人的信息!\n");
return;
}
if (ap == NULL) head = head->next;
else
ap->next = cp->next;
free(cp);
}
void AlterList(List head,char NAME,char newNAME,char newGENDER,char newTEL,char newCITY,char newEIP) {
List p = head;
while (p != NULL) {
if (strcmp(p->data.NAME, NAME) == 0);
{
printf("请输入要修改好友的信息!\n");
scanf("%s”,& newGENDER ;”%s”,& newTEL;”%s”,& newCITY ; “%s”,& newEIP ");
printf("修改成功的好友信息:newNAME:%s newGENDER:%s newTEL:%s newCITY:%s newEIP:%s\n");
}
}
p = p->next;
printf("通讯录中没有此人!\n");
return;
}
void AddList(Listhead,char item,int pos)
{
pos=-1;
Listnewptr;
newptr=malloc(sizeof(List));
newptr=item;
Listcp=head;
Listap=NULL;
while(cp!=NULL){
ap=cp;
cp=cp->next;
}
if(ap==NULL){
newptr->next=head;
head=newptr;
}
else
{
newptr->next=cp;
ap->next=newptr;
}
return;
}
void ListList(Listhead)
{
List*p=head;
while(p!=NULL){
printf("NAME:%s", p->data.NAME);
printf("GENDER:%s", p->data.GENDE
while没有加大括号啊