From a23b8ed0baf05cc49d937068b53cd4e00d18b8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E9=9B=A8?= <389919422@qq.com> Date: Wed, 9 Jan 2019 16:42:52 +0800 Subject: [PATCH] 3c commit --- 最终-通讯录管理系统.cpp | 252 +++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 最终-通讯录管理系统.cpp diff --git a/最终-通讯录管理系统.cpp b/最终-通讯录管理系统.cpp new file mode 100644 index 0000000..4b33f39 --- /dev/null +++ b/最终-通讯录管理系统.cpp @@ -0,0 +1,252 @@ +#include +#include +#include +#define LEN sizeof(phone) +static int count=0; +FILE *ptr1; +struct txl //ͨṹ巽㴢˵ĸ +{ + char name[10]; + char hometown[10]; + char number1[15]; + char number2[15]; + char e_mail[30]; +}phone[100]; //ͨṹԴ˵ + +void tianjia() +{ + system("cls"); + static int i=0; //ʹstatic Ѿ + int j,t; + struct txl *p; + p=phone; + printf("Կʼ\n"); + printf("绰Ųܳ11,!\n"); + printf("䲻ܳ10ַ~~\n"); + ptr1=fopen("sto3.txt","ab+"); + if(ptr1==NULL) + { + ptr1=fopen("sto3.txt","wb+"); + if(ptr1==NULL) + { + printf("Cannot open file"); + exit(0); + } + } + fseek(ptr1,0,SEEK_END);//ʹļָָļĩβʹµ + do + { + printf(":"); + scanf("%s",&p[i].name); printf("\n"); + printf("뼮:"); + scanf("%s",&p[i].hometown); printf("\n"); + printf("绰1:"); + scanf("%s",&p[i].number1);printf("\n"); + printf("绰2:"); + scanf("%s",&p[i].number2); printf("\n"); + printf(":"); + scanf("%s",&p[i].e_mail); printf("\n"); + fwrite(&p[i],LEN,1,ptr1); + printf("һ,Ƿ\n "); + printf("1Ϊ 0Ϊ˳\n"); + fflush(stdin); //ջ棬ݽ뵽ļУΪݴСû512bļʹǿƵĽļ + scanf("%d",&j); + i++;count++; + }while(j!=0&&count!=100); + fclose(ptr1); +} +void chakan()//鿴ҵϵ +{ + system("cls"); + 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