通讯录管理系统
的有关信息介绍如下:
我这里有一个,你看看吧,满意的给分哦(在visual c++6.0上运行)#include #include /*使用字符串函数*/#include /*使用通过控制台进行数据输入和数据输出的函数*/#include#include /*使用DOS函数*/int i; /*定义一个全局变量i*/struct addr /*定义通讯地址结构体*/{ char post_num[10]; /*邮编*/ char addr[60]; /*家庭地址*/};struct birth /*定义出生年月结构体*/{ int year; /*年份*/ int month; /*月份*/ int day; /*日期*/};struct record1 /*定义电子通讯录结构体*/{ int number; /*序号*/ char name[20]; /*姓名*/ char sex; /*性别*/ struct birth birth; /*出生年月*/ struct addr addr; /*通信地址*/ char telephone[13]; /*联系电话*/}records[50];FILE *fp; /*定义指向file类型结构体的指针变量*/void Data_Load() /*定义载入数据函数*/{ int j; long k; fp=fopen("record.txt","r+t"); /*打开文件record.txt,进行读写*/ if(fp!=NULL) /*如果文件不为空*/ { for(i=1;i<50;i++) { j=fgetc(fp); /*从"records.txt"文件读入整型数字*/ if(j==EOF) /*判断是否到了文件尾*/ return; /*如果到了结尾,返回*/ k=i-1; fseek(fp,k*sizeof(struct record1),SEEK_SET); /*将位置指针移到record1结构体所含字节的第k倍个字节处*/ fread(&records[i],sizeof(struct record1),1,fp); /*读取一条记录*/ } } else { fp=fopen("record.txt","w"); /*打开文件record.txt,只写*/ i=1; }}void Data_Show(int j) /*定义显示数据函数*/{printf("\n\n\tNo:%3d\n",records[j].number); /*序号*/printf("\n\tname:%2s\n",records[j].name); /*姓名*/ printf("\n\tbirthday (y/m/d):%4d%2d%2d", records[j].birth.year, records[j].birth.month, records[j].birth.day); /*打印第j个成员的出生年月日*/ printf("\n\tpost code:%-10s",records[j].addr.post_num); /*邮编*/ printf("\n\taddress:%-40s",records[j].addr.addr); /*家庭地址*/ printf("\n\tphone%-13s",records[j].telephone); /*联系电话*/}void Data_Input(int j) /*定义添加数据函数*/{ fflush(stdin); /*清空输入缓冲区*/ records[j].number=j; printf("\n\n\n\tinputNo %d ",j); printf("\n\tname:"); /*输入姓名*/ scanf("%s",records[j].name); fflush(stdin); /*清空输入缓冲区*/ printf("\tsex(m/f):"); /*输入性别*/ scanf("%c",&records[j].sex); printf("\t---birthday---"); /*输入出生年月*/ printf("\n\tyear:"); scanf("%d",&records[j].birth.year); printf("\tmonth:"); scanf("%d",&records[j].birth.month); printf("\tday:"); scanf("%d",&records[j].birth.day); printf("\tpost code:"); /*输入邮编*/ scanf("%s",records[j].addr.post_num); printf("\taddress:"); /*输入家庭地址*/ scanf("%s",records[j].addr.addr); printf("\tphone:"); /*输入联系电话*/ scanf("%s",records[j].telephone);}void Data_Save() /*定义保存函数*/{ int j; fp=fopen("record.txt","w"); /*打开文件record.txt,只写*/ for(j=1;j<=i;j++) { fwrite(&records[j],sizeof(struct record1),1,fp); /*将结构体变量records的确定个数字节输入到record.txt文件中,个数为结构体friend1所含字节数*/ }}void main() /*主函数*/{ int j,k; char ch; char search_name[40]; /*定义字符串变量*/ Data_Load(); /*声明载入数据函数*/ i--; do { printf("********************************* MENU ***************************************\n"); printf("------------------------! WELLCOME TO THE SYSTEM !------------------------------"); printf("\n*\tSelect Function: *"); printf("*\t1.Add New *"); printf("*\t2.View the data *"); printf("*\t3.Delete *"); printf("*\t4.Search *"); printf("*\t5.Insert *"); printf("*\t6.Save and quit *"); printf("*\t7.Quit *"); printf("\n******************************** MENU ****************************************\n"); printf("\tPlease choose the option you need:"); ch=getche(); /*输入字符*/ switch(ch) { case '1': { int p; printf("\n\tPlease input the number of people you want to add:"); scanf("%d",&p);/*增加记录*/ printf("\tPlease press ENTER again"); while(getch()!=0x1b&&ii) printf("\n\tThe system is end\n"); /*显示记录末尾*/ break; case '3': /*删除通讯录中的记录*/ if(i<1) { printf("\n\tno record\n"); /*显示无记录*/ break; } printf("\n\tplease input the number you want to delect:"); scanf("%d",&k); printf("\tsucceed!\n"); for(j=k;ji) /*搜索失败*/ printf("\n\tNo Record "); /*显示无此记录*/ break; case '5': printf("\n\tInsert No:"); /*录入插入位置*/ scanf("%d",&k); for(j=k+1;j