|
|
@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
|
|
|
void add();
|
|
|
|
|
|
|
|
void change();
|
|
|
|
|
|
|
|
void find();
|
|
|
|
|
|
|
|
void ioad();
|
|
|
|
|
|
|
|
void mune();
|
|
|
|
|
|
|
|
void see();
|
|
|
|
|
|
|
|
void save();
|
|
|
|
|
|
|
|
char n[30];
|
|
|
|
|
|
|
|
int k=0;
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
struct tong
|
|
|
|
|
|
|
|
{ int num;
|
|
|
|
|
|
|
|
char name[30]; //名字
|
|
|
|
|
|
|
|
char jiguan[30]; //籍贯
|
|
|
|
|
|
|
|
char handset[30]; //手机
|
|
|
|
|
|
|
|
char handset2[30];
|
|
|
|
|
|
|
|
char email[30]; //电子邮件
|
|
|
|
|
|
|
|
}m[15]={0};
|
|
|
|
|
|
|
|
void load()//录入
|
|
|
|
|
|
|
|
{ int i;
|
|
|
|
|
|
|
|
char s[100];
|
|
|
|
|
|
|
|
printf("请输入文件名");
|
|
|
|
|
|
|
|
scanf("%s",s);
|
|
|
|
|
|
|
|
fp=fopen(s,"r+");
|
|
|
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("open error\n");
|
|
|
|
|
|
|
|
printf("请重新输入文件名");
|
|
|
|
|
|
|
|
load();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
printf("录入成功\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i=0;i<15;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%d%s%s%s%s%s",&m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("序号\t名字\t籍贯\t手机1\t手机2\t电子邮件\n");
|
|
|
|
|
|
|
|
for(i=0;i<15;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("%d\t%s\t%s\t%s\t%s\t%s\n",m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("按回车返回菜单");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void find()//寻找
|
|
|
|
|
|
|
|
{ int i;
|
|
|
|
|
|
|
|
printf("请输入要寻找的人的姓名\n");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
scanf("%s",n);
|
|
|
|
|
|
|
|
for(i=0;i<15;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (strcmp(m[i].name,n)==0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(i>15)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("查无此人\n");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
find();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%d\t%s\t%s\t%s\t%s\t%s\n",m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
printf("按回车返回菜单");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void add()//添加
|
|
|
|
|
|
|
|
{int i;
|
|
|
|
|
|
|
|
printf("请输入要添加人的信息\n\t\t\姓名\籍贯\手机号1\手机号2\邮件\n");
|
|
|
|
|
|
|
|
scanf("%s%s%s%s%s",m[k].name,m[k].jiguan,m[k].handset,m[k].handset2,m[k].email);
|
|
|
|
|
|
|
|
k++;
|
|
|
|
|
|
|
|
m[k-1].num=k;
|
|
|
|
|
|
|
|
printf("输入1继续添加,其它加回车返回菜单");
|
|
|
|
|
|
|
|
scanf("%d",&i);
|
|
|
|
|
|
|
|
if(i==1)
|
|
|
|
|
|
|
|
add();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void change()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char sr;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("请输入要修改人的名字\n");
|
|
|
|
|
|
|
|
scanf("%s",n);
|
|
|
|
|
|
|
|
for(i=0;i<15;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(m[i].name,n)==0)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%d",i);
|
|
|
|
|
|
|
|
if(i>15)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("无此人,请重输\n");
|
|
|
|
|
|
|
|
change();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%d\t%s\t%s\t%s\n%s\t%s\n",m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
printf("请输入修改后的信息\n");
|
|
|
|
|
|
|
|
printf("\t-----------确定要修改的信息------------\n");
|
|
|
|
|
|
|
|
printf("\t-----------名字扣1-----------\n");
|
|
|
|
|
|
|
|
printf("\t-----------籍贯扣2-----------\n");
|
|
|
|
|
|
|
|
printf("\t----------电话扣3----------\n");
|
|
|
|
|
|
|
|
printf("\t-----------电子邮件扣4-----------\n");
|
|
|
|
|
|
|
|
printf("\t--------------全部扣0------------\n");
|
|
|
|
|
|
|
|
scanf("%c",&sr);
|
|
|
|
|
|
|
|
do{
|
|
|
|
|
|
|
|
switch(sr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case '1':scanf("%s",m[i].name);break;
|
|
|
|
|
|
|
|
case '2':scanf("%s",m[i].jiguan);break;
|
|
|
|
|
|
|
|
case '3':scanf("%s%s",m[i].handset,m[i].handset2);break;
|
|
|
|
|
|
|
|
case '4':scanf("%s",m[i].email);break;
|
|
|
|
|
|
|
|
case '0':scanf("%d%s%s%s%s%s",&m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].email);break;
|
|
|
|
|
|
|
|
default:printf("输入错误");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(!(sr==1||sr==2||sr==3||sr==4));
|
|
|
|
|
|
|
|
printf("按回车返回菜单");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void see()
|
|
|
|
|
|
|
|
{ int i;
|
|
|
|
|
|
|
|
printf("序号\t名字\t籍贯\t手机1\t手机2\t电子邮件\n");
|
|
|
|
|
|
|
|
for(i=0;i<k;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("%d\t%s\t%s\t%s\t%s\t%s\n",m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("按回车键返回主页");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void mune()//菜单
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char c;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
printf("\t-----------通讯录程序------------\n");
|
|
|
|
|
|
|
|
printf("\t-----------文件录入扣1-----------\n");
|
|
|
|
|
|
|
|
printf("\t-----------信息浏览扣2-----------\n");
|
|
|
|
|
|
|
|
printf("\t----------联系人搜索扣3----------\n");
|
|
|
|
|
|
|
|
printf("\t-----------信息修改扣4-----------\n");
|
|
|
|
|
|
|
|
printf("\t------------添加扣5------------\n");
|
|
|
|
|
|
|
|
printf("\t----------保存扣6----------\n");
|
|
|
|
|
|
|
|
printf("\t--------------退出扣0------------\n");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
for(i=0;i<k;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("%d\t%s\t%s\t%s\t%s\t%s\n",m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
scanf("%c",&c);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(c)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case '1':system("color 2E");
|
|
|
|
|
|
|
|
load();break;
|
|
|
|
|
|
|
|
case '2':see();break;
|
|
|
|
|
|
|
|
case '3':find();break;
|
|
|
|
|
|
|
|
case '4':change();break;
|
|
|
|
|
|
|
|
case '5':add();mune();break;
|
|
|
|
|
|
|
|
case '6':save();break;
|
|
|
|
|
|
|
|
case '0':exit(0);
|
|
|
|
|
|
|
|
default:printf("!!!!!!!!输入错误,按回车重输\n");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
mune();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
|
|
|
system("color 3E");
|
|
|
|
|
|
|
|
fp=fopen("通讯录2.txt","r+");
|
|
|
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("通讯录文件录入失败\n");
|
|
|
|
|
|
|
|
printf("请输入重新录入的文件\n");
|
|
|
|
|
|
|
|
load();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
printf("通讯录录入成功请选择功能\n");
|
|
|
|
|
|
|
|
k=0;
|
|
|
|
|
|
|
|
for(i=0;i<15;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fscanf(fp,"%d%s%s%s%s%s",&m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
if((m[i].num)!=0)
|
|
|
|
|
|
|
|
k++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<k;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("%d\t%s\t%s\t%s\t%s\t%s\n",m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("按回车键进入菜单");
|
|
|
|
|
|
|
|
fflush(stdin);
|
|
|
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
mune();
|
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void save()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
rewind(fp);
|
|
|
|
|
|
|
|
for(i=0;i<k;i++)
|
|
|
|
|
|
|
|
fprintf(fp,"\n%d\t%s\t%s\t%s\t%s\t%s",m[i].num,m[i].name,m[i].jiguan,m[i].handset,m[i].handset2,m[i].email);
|
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
}
|