<span style="font-size:18px;">#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<malloc.h>
#include<conio.h>
#define LEN sizeof(struct ab)
#define ZIP 7
#define PHONE 7
#define MAX 100
struct ab
{
char name[10];
char addr[10];
char zip[ZIP];
char phone[PHONE];
struct ab *next;
};
struct ab *head;
void search(struct ab *head);
struct ab *add(struct ab *head);
struct ab *del(struct ab *head);
void alter(struct ab *head);
void print(struct ab *head);
void thefirst();
int n;</span>
<span style="font-size:18px;">#include"head.h"
void main()
{
n=0;
head=(struct ab *)malloc(LEN);
thefirst();
}
void thefirst()
{
char c;
system("CLS");
puts("**************************************");
puts(" 通讯录 ");
puts(" 1、查询 ");
puts(" 2、加入 ");
puts(" 3、删除 ");
puts(" 4、改动 ");
puts(" 5、显示 ");
puts(" 6、返回 ");
puts("**************************************");
c=getch();
system("CLS");
switch(c)
{
case '1':search(head);break;
case '2':head=add(head);thefirst();break;
case '3':head=del(head);thefirst();break;
case '4':alter(head);break;
case '5':print(head);break;
case '6':printf("BYE BYE!\n");
}
}</span>
<span style="font-size:18px;">#include"head.h"
void search(struct ab *head)
{
char str[10];
struct ab *p;
p=head;
printf("please input the name you want to search!\n");
scanf("%s",str);
if(p==NULL)
{
printf("please input the information first!press any key to thefirst \n");
getch();
thefirst();
}
system("CLS");
for(;p&&strcmp(str,p->name);p=p->next);
if(p)
printf("%10s\n%10s\n%10s\n%10s\n",p->name,p->addr,p->zip,p->phone);
else
printf("there is no information about the people you want!\n");
getch();
thefirst();
}</span>
<span style="font-size:18px;">#include"head.h"
struct ab *add(struct ab *head)
{
struct ab *p1,*p2,*p3;
char c[10];
printf("please input the name!\n");
scanf("%s",c);
p1=head;
if(n==0)
{
strcpy(p1->name,c);
printf("please input the address!\n");
scanf("%s",p1->addr);
printf("please input the zip!\n");
scanf("%s",p1->zip);
printf("please input the phone!\n");
scanf("%s",p1->phone);
printf("%s\n",p1->phone);
p1->next=NULL;
n++;
}
else
{
p3=(struct ab *)malloc(LEN);
strcpy(p3->name,c);
printf("please input the address!\n");
scanf("%s",p3->addr);
printf("please input the zip!\n");
scanf("%s",p3->zip);
printf("please input the phone!\n");
scanf("%s",p3->phone);
if(strcmp(c,p1->name)<0)
{
head=p3;
p3->next=p1;
}
else
{
for(;p1&&strcmp(c,p1->name)>0;p2=p1,p1=p1->next);
if(p1==NULL)
{
p2->next=p3;
p3->next=NULL;
}
else
{
p2->next=p3;
p3->next=p1;
}
n++;
}
}
return head;
}</span>
<span style="font-size:18px;">#include"head.h"
struct ab *del(struct ab *head)
{
struct ab *p1,*p2;
char c[10];
p1=head;
printf("please input the name you want to delete\n");
scanf("%s",c);
for(;p1&&strcmp(c,p1->name);p2=p1,p1=p1->next);
if(p1==NULL)
{
printf("not find!press any key to thefirst \n");
getch();
}
else if(p1==head)
head=p1->next;
else
p2->next=p1->next;
return head;
}</span>
<span style="font-size:18px;">#include"head.h"
void alter(struct ab *head)
{
char str[10];
struct ab *p;
p=head;
printf("please input the name you want to search!\n");
scanf("%s",str);
for(;p&&strcmp(str,p->name);p=p->next);
if(p)
{
printf("please input the address!\n");
scanf("%s",p->addr);
printf("please input the zip!\n");
scanf("%s",p->zip);
printf("please input the phone!\n");
scanf("%s",p->phone);
}
else
{
printf("not find!press any key to thefirst \n");
getch();
}
thefirst();
}
</span>
<span style="font-size:18px;">#include"head.h"
void print(struct ab *head)
{
struct ab *p;
for(p=head;p;p=p->next)
{
printf("%10s%10s%10s%10s\n",p->name,p->addr,p->zip,p->phone);
}
getch();
thefirst();
}</span>

C语言实现通讯录的更多相关文章

  1. C语言之通讯录的模拟实现

    C语言之通讯录的模拟实现 在C语言学习结束之际,谨以此篇文章来对C语言的学习告一段落. 纲要: 通讯录的静态版本 通讯录的动态版本 通讯录的带文件版本 因为三种实现方法除了储存形式不同,其他都基本相同 ...

  2. c语言实现通讯录管理系统(c课程设计)

    工具:Visual C++6.0 说明: 本系统基于C语言实现班级通讯录管理系统,为大一时学习C语言刚入门所做的课程设计.功能包括增.删.查.改等,非常适合初学者练手.通讯录包括的个人信息有姓名.学号 ...

  3. C语言-《通讯录》

    黑白的通讯录 --1-- 需求分析 1.1 需求 1.2 原型展示 1.3 功能分析 --2-- 代码实现 2.1 外部声明.变量.宏 2.2 模块实现 ----------------------- ...

  4. Iphone 英语语言下通讯录排序问题

    Iphone 如果把界面语言设置成English,那么通讯录默认排序是通过拼音来排的,如果联系人信息中没有设置名字的拼音,那么这些联系人都会被放到#中. 批量添加拼音的解决方案: https://gi ...

  5. 2、C语言实现通讯录

    main函数入口: //test.c #include<stdio.h> #include<stdlib.h> #include<string.h> #includ ...

  6. C语言可以开发哪些项目?

    C语言是我们大多数人的编程入门语言,对其也再熟悉不过了,不过很多初学者在学习的过程中难免会出现迷茫,比如:不知道C语言可以开发哪些项目,可以应用在哪些实际的开发中--,这些迷茫也导致了我们在学习的过程 ...

  7. (一〇一)集成静态库RHAddressBook实现OC访问通讯录

    使用官方的AddressBook框架仅能使用C语言访问通讯录,十分不便,这里介绍集成第三方框架RHAddressBook的方法,该框架可以通过OC访问和操作通讯录. 该框架是一个静态库,集成比较复杂. ...

  8. C语言可以开发哪些项目?(转)

    原文地址:https://www.cnblogs.com/shiyanlou/p/6098661.html 知乎:https://www.zhihu.com/question/20564904 C语言 ...

  9. 17个C语言可以做的小案例项目

    C语言是我们大多数人的编程入门语言,对其也再熟悉不过了,不过很多初学者在学习的过程中难免会出现迷茫,比如:不知道C语言可以开发哪些项目,可以应用在哪些实际的开发中……,这些迷茫也导致了我们在学习的过程 ...

随机推荐

  1. Windows Phone 8初学者开发的翻译终于过半

    从2013年7月19日开始,到2013年12月9日,一共花了143天时间完成了18篇Windows Phone 8初学者开发的翻译,还剩下17篇文章需要翻译,看到了完成的希望! I love Wind ...

  2. redisTemplate 操作

    redisDao封装类-其他dao集成他 package com.ffcs.wlan.dao.common; import javax.annotation.Resource; import org. ...

  3. 使用POI创建Excel文件下载

    POIExcelUtils.java: package com.saicfc.pmpf.internal.manage.utils; import java.io.File; import java. ...

  4. Android 它们的定义View视图

    创建一个新视图将满足我们独特UI需求. 本文介绍的发展将指南针罗盘接口使用UI,通过继承View定义自己的视图类工具,为了深入了解自己的自定义视图. 实现效果图: 源码: 布局文件activity_m ...

  5. hdoj 1286 找新朋友 【数论之欧拉函数】

    找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  6. python模块介绍- HTMLParser 简单的HTML和XHTML解析器

    python模块介绍- HTMLParser 简单的HTML和XHTML解析器 2013-09-11 磁针石 #承接软件自动化实施与培训等gtalk:ouyangchongwu#gmail.comqq ...

  7. 反射API

    反射,是指一种能在运行时动态加载.分析类的能力.反射被广泛地用于那些需要在运行时检测或修改程序行为的程序中.这是一个相对高级的特性,使用反射技术应当具备相当的Java语言基础.我们可以通过反射机制让应 ...

  8. Canny边缘检測算法原理及其VC实现具体解释(一)

    图象的边缘是指图象局部区域亮度变化显著的部分,该区域的灰度剖面一般能够看作是一个阶跃,既从一个灰度值在非常小的缓冲区域内急剧变化到还有一个灰度相差较大的灰度值.图象的边缘部分集中了图象的大部分信息,图 ...

  9. [置顶] 单键模式的C++描述

    设计模式-单键(Signelton):其实单键的设计模式说来很简单,说的直白一点就是程序运行过程中保证只有一个实例在运行而已.在软件系统中,经常有这样一些特殊的类,必须保证它们在系统中只存在一个实例, ...

  10. 通过崩溃地址找错误行数之Delphi版

    通过崩溃地址找错误行数之Delphi版2009-5-11 17:42:35 来源: 转载 作者:网络 访问:360 次 被顶:2 次 字号:[大 中 小]核心提示:什么是 MAP 文件?简单地讲, M ...