链表实现通讯录

初学者 第一次写通讯录,写到头皮发麻。

灵活运用指针函数,返回值为指针

注意使用二级指针操作头指针head

注意del函数的判断条件
切记不骄不躁!

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>

#define LEN sizeof(struct information)
//定义结构体
typedef struct information
{
    char name[20];
    char id[20];
    char phone[20];
    char home[20];
    struct information *next;
}INFO;

//主菜单函数
void face()
{
    printf("******address list*****\n");
    printf("1:show  all information\n");
    printf("2:add       information\n");
    printf("3:delete    information\n");
    printf("4:modify    information\n");
    printf("5:search    information\n");
    printf("0:quit\n");
    printf("***********************\n");
}
//显示所有联系人
INFO *print(INFO *head)
{
    INFO *p;
    p = head;
    //system("clear");

    if(head != NULL)
    {
    	 printf("***********************\n");
        printf("members are as follow!\n");
        while(p != NULL)
        {
            printf("name:%s\t",p->name);
            printf("id:%s\t",p->id);
            printf("phone:%s\t",p->phone);
            printf("home:%s\n",p->home);
            p = p->next;
        }
    }

    else
    {
    	 printf("***********************\n");
        printf("address_list is none!\n");
    }
    return head;
}
//增加联系人函数
INFO *add(INFO *head)
{
	INFO *new_node = (INFO*)malloc(LEN);
	
    printf("***********************\n");
    printf("please input name!\n"
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值