没有合适的资源?快使用搜索试试~ 我知道了~
系统函数的在red hat 下c编程基本的应用 1、 通讯录采用struct定义结构; 2、 通讯录数据使用malloc动态分配内存,而不要使用静态数组; 3、 尽量把通讯录列表建成一种单向链表的形式,提高新增和删除的效率。
资源推荐
资源详情
资源评论
#include<stdio.h>
#include<string.h>
#include "stdio.h"
#include "malloc.h"
struct friends_list{
int id;/* 学号*/
char name[10];/* 姓名*/
char telephone[13];/* 电话号码 */
};
int Count=0;/* 电话痛迅录为0 */
void new_friend(struct friends_list friends[]);/* 自定义添加通讯录函数 */
void search_friend(struct friends_list friends[],char*name);/* 自定义查找通迅录函数*/
void Modify_friend(struct friends_list friends[],char*name);/* 自定义修改通迅录函数*/
void Delete_friend(struct friends_list friends[],char*name,int n);/* 自定义删除通迅录函数*/
/* mian 函数*/
int main(void)
{
int choice,n;
char name[10];
struct friends_list friends[(char*)malloc(100*sizeof(char))];
do{
printf("手机通讯录功能选项: 1:新建 2:查询 3:修改 4:删除 0:退出\n");
printf("请选择功能:");
scanf("%d",&choice);
switch(choice){
case 1:
new_friend(friends);
break;
case 2:
printf("请输入要查找的联系人姓名:");
#include<string.h>
#include "stdio.h"
#include "malloc.h"
struct friends_list{
int id;/* 学号*/
char name[10];/* 姓名*/
char telephone[13];/* 电话号码 */
};
int Count=0;/* 电话痛迅录为0 */
void new_friend(struct friends_list friends[]);/* 自定义添加通讯录函数 */
void search_friend(struct friends_list friends[],char*name);/* 自定义查找通迅录函数*/
void Modify_friend(struct friends_list friends[],char*name);/* 自定义修改通迅录函数*/
void Delete_friend(struct friends_list friends[],char*name,int n);/* 自定义删除通迅录函数*/
/* mian 函数*/
int main(void)
{
int choice,n;
char name[10];
struct friends_list friends[(char*)malloc(100*sizeof(char))];
do{
printf("手机通讯录功能选项: 1:新建 2:查询 3:修改 4:删除 0:退出\n");
printf("请选择功能:");
scanf("%d",&choice);
switch(choice){
case 1:
new_friend(friends);
break;
case 2:
printf("请输入要查找的联系人姓名:");
scanf("%s",name);
search_friend(friends,name);
break;
case 3:
printf("请输入您要修改的联系人的姓名:");
scanf("%s",name);
printf("\n");
Modify_friend(friends,name);
break;
case 4:
printf("1:单个删除 2:全部删除\n\n");
printf("请选择您需要的操作:\n");
scanf("%d",&n);
if(n==1){
printf("输入名字\n");
scanf("%s",name);
Delete_friend(friends,name,n);
break;
}
if(n==2){
Delete_friend(friends,name,n);
break;
}
case 0: break;
}
}while(choice!=0);
printf("谢谢使用通讯录功能!\n");
return 0;
}
void new_friend(struct friends_list friends[ ])
search_friend(friends,name);
break;
case 3:
printf("请输入您要修改的联系人的姓名:");
scanf("%s",name);
printf("\n");
Modify_friend(friends,name);
break;
case 4:
printf("1:单个删除 2:全部删除\n\n");
printf("请选择您需要的操作:\n");
scanf("%d",&n);
if(n==1){
printf("输入名字\n");
scanf("%s",name);
Delete_friend(friends,name,n);
break;
}
if(n==2){
Delete_friend(friends,name,n);
break;
}
case 0: break;
}
}while(choice!=0);
printf("谢谢使用通讯录功能!\n");
return 0;
}
void new_friend(struct friends_list friends[ ])
剩余7页未读,继续阅读
资源评论
sinat_33367016
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功