#include
#include
#include
#include
static char *initialization_pas;
static char *password_you_entered;
static char *password_you_entering;
struct info
{
? ? ? ? char name[15];
? ? ? ? char phone[12];
? ? ? ? char sex[2];
? ? ? ? char age[4];
? ? ? ? char address[20];
};
void Initial();
void InitializationPassword();
void EnterPassword();
void Panel();
void FormatOutputInfo(struct info a);
void New();
void Modify();
void Delet();
void Display();
void Search();
void ModifyPassword();
void AdministratorInterface();
void NormalUserInterface();
void SelectOption(int *a);
void ExecutiveFunction1(int *a);
void ExecutiveFunction2(int *a);
void InterfaceOfAdministratorPrivilege();
void InterfaceOfNormalUserPrivilege();
void Initial()
{
? ? ? ? FILE *fp;
? ? ? ? if((fp=fopen("password.txt","wb")) == NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow opening file!!!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? ? ? printf("please enter the initialization password:");
? ? ? ? gets(initialization_pas);
? ? ? ? fwrite(initialization_pas,1,10,fp);
? ? ? ? printf("initialization_pas is %s\n", initialization_pas);上海整形医院http://zx.daynews.com.cn/
? ? ? ? fclose(fp);
}
void InitializationPassword()
{
? ? ? ? long len;
? ? ? ? FILE *fp;
? ? if((fp=fopen("password.txt","ab"))==NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow opening file!!!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? ? ? fseek(fp,0,2);
? ? ? ? ? ? ? ? len=ftell(fp);
? ? ? ? ? ? ? ? if(len==0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? puts("password.txt is empty!!!");
? ? ? ? ? ? ? ? ? ? ? ? fclose(fp);
? ? ? ? ? ? ? ? ? ? ? ? Initial();
? ? ? ? ? ? ? ? }
? ?? ???else
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? fclose(fp);
? ?? ?? ?? ?fp=fopen("password.txt","rb");
? ? ? ? ? ? ? ? ? ? ? ? fread(password_you_entered,1, 10, fp);
? ? ? ? ? ? ? ? ? ? ? ? fclose(fp);
? ? ? ? ? ? ? ? }
? ? ? ? }
}
void EnterPassword()
{
? ? ? ? printf("the password had exist, please enter it correct:");
? ? ? ? gets(password_you_entering);
? ? ? ? printf("you entered is %s\n", password_you_entering);
? ? ? ? getch();
}
void Panel()
{
? ? ? ? printf("%-15s %-12s %-4s %-4s %-21s","name","phone","sex","age","address");
}
void FormatOutputInfo(struct info a)
{
? ? ? ? printf("%-15s %-12s %-4s %-4s %-21s\n", a.name, a.phone, a.sex, a.age, a.address);
}
void New()
{
? ? ? ? char b;
? ? ? ? struct info a;
? ? ? ? FILE *fp;
? ? ? ? if((fp=fopen("information.txt","ab")) == NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow open file!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? ? ? do
? ? ? ? {
? ? ? ? ? ? ? ? system("CLS");
? ? ? ? ? ? ? ? puts("input information:");
? ? ? ? ? ? ? ? printf("\tname:");
? ? ? ? ? ? ? ? gets(a.name);
? ? ? ? ? ? ? ? printf("\tphone:");
? ? ? ? ? ? ? ? gets(a.phone);
? ? ? ? ? ? ? ? printf("\tsex:");
? ? ? ? ? ? ? ? gets(a.sex);
? ? ? ? ? ? ? ? printf("\tage:");
? ? ? ? ? ? ? ? gets(a.age);
? ? ? ? ? ? ? ? printf("\taddress:");
? ? ? ? ? ? ? ? gets(a.address);
? ? ? ? ? ? ? ? fwrite(&a,sizeof(info),1,fp);
? ? ? ? ? ? ? ? printf("是否继续?(Y):[ ]\b\b");??/*这里用空格键有个BUG */
? ?? ???b=getchar();getchar();
? ? ? ? }while(b=='Y' || b=='y');
? ? ? ? fclose(fp);
}
void Modify()
{
? ? ? ? struct info a;
? ? ? ? char b[20];
? ? ? ? FILE *fp1, *fp2;
? ? ? ? ? ? ? ? if((fp1=fopen("information.txt","rb")) == NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow open file!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? ? ? if((fp2=fopen("temp.txt","wb")) == NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow open file!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? pr |