设为首页 加入收藏

TOP

新人写的通讯录和简短日历(一)
2015-01-22 21:12:32 来源: 作者: 【 】 浏览:68
Tags:新人 通讯录 简短 日历
#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
首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇[程序示例]Objective-C中的委托设.. 下一篇c程序的启动过程的反汇编分析

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: