<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. hdu4431 Mahjong

    Mahjong Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  2. HDU 2544 最短

    链接:http://acm.hdu.edu.cn/showproblem.php? pid=2544 解析: 首先数据量为V<=100 那么这里使用不论什么基础的最短路的算法都不会超时! 常见数 ...

  3. 网页内容的html标签补全和过滤的两种方法

    网页内容的html标签补全和过滤的两种方法: 假设你的网页内容的html标签显示不全,有些表格标签不完整而导致页面混乱,或者把你的内容之外的局部html页面给包括进去了,我们能够写个函数方法来补全ht ...

  4. FMX对象释放

    今天盒子中有朋友遇到对象释放的问题,原文在这里,他的实现大意是建立一个TmyLayout = class(TLayout),然后在这个类中画线,Form对象调用实例化这个类来画线,然后释放掉这个对象, ...

  5. 单选按钮、复选按钮——axure线框图部件库介绍

    有时候发现这做事情坚持下来是一件很不容易的,写教程也一样,不过听到很多朋友对我说 这个全部是图片的教程 对他们入门帮助很多,我就想想 在坚持坚持把基础部分先完善了! 1. 简单的问卷调查: 您的性别? ...

  6. 最新 Druid 配置

    Druid是一个JDBC组件库,包括数据库连接池.SQL Parser等组件.DruidDataSource是最好的数据库连接池.下面我们就一起来在项目中配置Druid吧 1.Druid依赖配置 &l ...

  7. hdu4709求三角形面积

    Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  8. Unity 3D 文件导入出错

    Unity 3D 文件导入出错 安装unity 时我选择了free版的,打开已有项目时出现例如以下错误提示 解决的方法: 先把要导入的文件先复制到unity3d安装文件夹下相应的文件夹内,之后再返回u ...

  9. 使用BigDecimal来进行精确计算

    在一些以金融等行业中的计算是需要十分精确的,即使我们使用像double这样的类型,由于浮点数的原因,会使得数据计算变得不精确,例如下面的例子: double a = 0.1; double b = 0 ...

  10. adb 命令使用的时候出现Error

    在使用adb 命令行的时候会出现Error 重启adb server 即可,使用管理员运行Cmd 命令窗口 adb kill-server adb start-server 如果是连接真机查看的时候再 ...