From e4caca44fa78cadfc658aa8b5608d38340f05d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=8E=E5=87=89?= <2312524043@qq.com> Date: Tue, 8 Jan 2019 09:52:37 +0800 Subject: [PATCH] 3 commit --- h1.h | 15 +++++++++++++++ h3.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 h1.h create mode 100644 h3.c diff --git a/h1.h b/h1.h new file mode 100644 index 0000000..ce6ea59 --- /dev/null +++ b/h1.h @@ -0,0 +1,15 @@ +#include +#include +#include +#define LEN sizeof(phone) +static int count=0; +FILE *ptr1; +struct txl //通过结构体方便储存个人的各项数据 +{ + char name[10]; + char hometown[10]; + char number1[11]; + char number2[11]; + char e_mail[10]; +}phone[100]; //通过结构体数组可以储存多人的数据 + diff --git a/h3.c b/h3.c new file mode 100644 index 0000000..0befb60 --- /dev/null +++ b/h3.c @@ -0,0 +1,63 @@ +void chakan()//查看需查找的联系人 +{ + FILE *ptr1; + struct txl *p; + p=phone; + char name[10]; + int j=0,i,m=0; + p=phone; + ptr1=fopen("sto3.txt","rb"); + if(ptr1==NULL) + { + printf("通讯录为空\n"); + return; + } +// rewind(ptr1); + while(!feof(ptr1)) + { + if(fread(&p[m],LEN,1,ptr1)==1)//将文件里的数据赋值给结构体数组,因此才可以进行数据的对比找到联系人 + m++; + } + fclose(ptr1); + printf("请输入你需要查看人的姓名:"); + scanf("%s",&name); + printf(" 所有同名的人都在这:\n"); + printf("姓名 籍贯 电话 电话 邮箱\n"); + for(i=0;i