|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <process.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
//<2F><><EFBFBD>庯<EFBFBD><E5BAAF>
|
|
|
|
|
FILE *fp; //<2F>ļ<EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
void menu();
|
|
|
|
|
void add();
|
|
|
|
|
void search();
|
|
|
|
|
void modify();
|
|
|
|
|
void look();
|
|
|
|
|
void quit();
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
menu();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
//ͨѶ¼<D1B6>ṹ<EFBFBD><E1B9B9>
|
|
|
|
|
struct user
|
|
|
|
|
{
|
|
|
|
|
char name[8]; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
char place[15]; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
char tel1[15]; //<2F>绰1
|
|
|
|
|
char tel2[15]; //<2F>绰2
|
|
|
|
|
char email[20]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}user[50];
|
|
|
|
|
//<2F>˵<EFBFBD>
|
|
|
|
|
void menu()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color f3");
|
|
|
|
|
int n;
|
|
|
|
|
printf("\n\n\n\n\n");
|
|
|
|
|
printf("\t\t:---------ͨѶ¼---------:\n");
|
|
|
|
|
printf("\t\t: 1:<3A>½<EFBFBD> :\n");
|
|
|
|
|
printf("\t\t: 2:<3A><>ѯ :\n");
|
|
|
|
|
printf("\t\t: 3:<3A><EFBFBD> :\n");
|
|
|
|
|
printf("\t\t: 4:<3A><><EFBFBD><EFBFBD> :\n");
|
|
|
|
|
printf("\t\t: 5:<3A>˳<EFBFBD> :\n");
|
|
|
|
|
printf("\t\t:--<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <1-5>ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--:\n\n");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
switch(n)
|
|
|
|
|
{
|
|
|
|
|
case 1: add(); break; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
case 2: search(); break; //<2F><>ѯ
|
|
|
|
|
case 3: modify(); break; //<2F><EFBFBD>
|
|
|
|
|
case 4: look(); break; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
case 5: return; break; //<2F>˳<EFBFBD>
|
|
|
|
|
default: return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣ
|
|
|
|
|
void add()
|
|
|
|
|
{
|
|
|
|
|
struct user one;
|
|
|
|
|
system("color e3");
|
|
|
|
|
if((fp=fopen("user.txt","ab"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",one.name);
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",one.place);
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>绰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",one.tel1);
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>绰<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%s",one.tel2);
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䣺");
|
|
|
|
|
scanf("%s",one.email);
|
|
|
|
|
fwrite(&one,sizeof(struct user),1,fp); //<2F><><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>¼<EFBFBD><C2BC>user.txt<78><74>
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("\nע<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
system("pause");
|
|
|
|
|
menu();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//<2F><EFBFBD>
|
|
|
|
|
void modify()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ѯ
|
|
|
|
|
void search()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
void look()
|
|
|
|
|
{
|
|
|
|
|
char c;
|
|
|
|
|
if((fp=fopen("user.txt","r"))==NULL) //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>user.txt
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>Ϣʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
int m=0;
|
|
|
|
|
while(!feof(fp))
|
|
|
|
|
{
|
|
|
|
|
if(fread(&user[m],sizeof(struct user),1,fp)==1)
|
|
|
|
|
m++;
|
|
|
|
|
}
|
|
|
|
|
int i;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t\t<EFBFBD>绰1\t\t<EFBFBD>绰2\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
for(i=0;i<m;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%-8s\t",user[i].name);
|
|
|
|
|
printf("%-15s\t",user[i].place);
|
|
|
|
|
printf("%-15s\t",user[i].tel1);
|
|
|
|
|
printf("%-15s\t",user[i].tel2);
|
|
|
|
|
printf("%-20s\t",user[i].email);
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
if(fclose(fp)) //<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
scanf("%c",&c);
|
|
|
|
|
printf("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y/N<><4E><EFBFBD><EFBFBD>");
|
|
|
|
|
scanf("%c",&c);
|
|
|
|
|
if(c=='y'||c=='Y')
|
|
|
|
|
menu();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//<2F>˳<EFBFBD>
|
|
|
|
|
void quit()
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|