|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#define LEN sizeof(phone)
|
|
|
|
|
static int count=0;
|
|
|
|
|
FILE *ptr1;
|
|
|
|
@ -20,10 +21,12 @@ void tianjia()
|
|
|
|
|
struct txl *p;
|
|
|
|
|
p=phone;
|
|
|
|
|
printf("可以开始添加\n");
|
|
|
|
|
ptr1=fopen("sto.txt","ab+");
|
|
|
|
|
printf("电话号不能超过11个呦,亲!\n");
|
|
|
|
|
printf("电子邮箱不能超过10个字符呦~~\n");
|
|
|
|
|
ptr1=fopen("sto3.txt","ab+");
|
|
|
|
|
if(ptr1==NULL)
|
|
|
|
|
{
|
|
|
|
|
ptr1=fopen("sto.txt","wb+");
|
|
|
|
|
ptr1=fopen("sto3.txt","wb+");
|
|
|
|
|
if(ptr1==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("Cannot open file");
|
|
|
|
@ -60,7 +63,12 @@ void chakan()//
|
|
|
|
|
char name[10];
|
|
|
|
|
int j=0,i,m=0;
|
|
|
|
|
p=phone;
|
|
|
|
|
ptr1=fopen("sto.txt","rb");
|
|
|
|
|
ptr1=fopen("sto3.txt","rb");
|
|
|
|
|
if(ptr1==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("通讯录为空\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// rewind(ptr1);
|
|
|
|
|
while(!feof(ptr1))
|
|
|
|
|
{
|
|
|
|
@ -91,7 +99,12 @@ void daying()//
|
|
|
|
|
FILE *ptr1;
|
|
|
|
|
int i,m=0;
|
|
|
|
|
p=phone;
|
|
|
|
|
ptr1=fopen("sto.txt","rb");
|
|
|
|
|
ptr1=fopen("sto3.txt","rb");
|
|
|
|
|
if(ptr1==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("通讯录为空\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// rewind(ptr1);
|
|
|
|
|
while(!feof(ptr1))
|
|
|
|
|
{
|
|
|
|
@ -112,7 +125,12 @@ void shanchu()
|
|
|
|
|
p=phone;
|
|
|
|
|
int i,j=0,m=0;
|
|
|
|
|
FILE *ptr1;
|
|
|
|
|
ptr1=fopen("sto.txt","rb");
|
|
|
|
|
ptr1=fopen("sto3.txt","rb");
|
|
|
|
|
if(ptr1==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("通讯录为空\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
rewind(ptr1);
|
|
|
|
|
while(!feof(ptr1))
|
|
|
|
|
{
|
|
|
|
@ -132,7 +150,7 @@ void shanchu()
|
|
|
|
|
j=1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ptr1=fopen("sto.txt","w");
|
|
|
|
|
ptr1=fopen("sto3.txt","w");
|
|
|
|
|
for(i=0;i<m-1;i++)
|
|
|
|
|
{
|
|
|
|
|
fwrite(&p[i],LEN,1,ptr1);
|
|
|
|
@ -151,7 +169,12 @@ void xiugai()
|
|
|
|
|
char name[10],mail[10];
|
|
|
|
|
int j,i,m=0;
|
|
|
|
|
p=phone;
|
|
|
|
|
ptr1=fopen("sto.txt","rb");
|
|
|
|
|
ptr1=fopen("sto3.txt","rb");
|
|
|
|
|
if(ptr1==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("通讯录为空\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// rewind(ptr1);
|
|
|
|
|
while(!feof(ptr1))
|
|
|
|
|
{
|
|
|
|
@ -163,6 +186,7 @@ void xiugai()
|
|
|
|
|
printf("姓名:");scanf("%s",&name);printf("\n");
|
|
|
|
|
printf("邮箱:");scanf("%s",&mail);printf("\n");
|
|
|
|
|
for(i=0;i<m;i++)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(p[i].name,name)==0&&strcmp(p[i].e_mail,mail)==0)
|
|
|
|
|
{
|
|
|
|
|
printf(" 选择修改的内容\n");
|
|
|
|
@ -185,8 +209,13 @@ void xiugai()
|
|
|
|
|
}
|
|
|
|
|
}while(j!=0);
|
|
|
|
|
}
|
|
|
|
|
ptr1=fopen("sto.txt","w");
|
|
|
|
|
for(i=0;i<m-1;i++)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("没有此人\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ptr1=fopen("sto3.txt","w");
|
|
|
|
|
for(i=0;i<m;i++)
|
|
|
|
|
{
|
|
|
|
|
fwrite(&p[i],LEN,1,ptr1);
|
|
|
|
|
}
|
|
|
|
@ -204,12 +233,13 @@ int main()
|
|
|
|
|
printf(" 4.修改电话簿\n");
|
|
|
|
|
printf(" 5.浏览所有联系人\n");
|
|
|
|
|
printf(" 0.退出电话簿\n");
|
|
|
|
|
// printf(" 7.ÇåÆÁ\n");
|
|
|
|
|
printf(" 制作者:通3林雨-李梓玲\n");
|
|
|
|
|
printf("======================================\n");
|
|
|
|
|
printf(" 请输入操作序号;");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
case 1:tianjia();break;
|
|
|
|
|
case 2:chakan();break;
|
|
|
|
|
case 3:shanchu();break;
|
|
|
|
@ -217,5 +247,6 @@ int main()
|
|
|
|
|
case 5:daying();break;
|
|
|
|
|
}
|
|
|
|
|
}while(choice!=0);
|
|
|
|
|
printf("本次使用结束!感谢你对本产品的支持!么么哒~~~\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|