崩天恨雨 英文:请帮帮我。。。。。

来源:百度文库 编辑:高校问答 时间:2024/05/05 00:47:23
我先设计了一个设置password的程序,然后将信息存储到一个文件当中,用*file来实现的。然后我需要设计一个程序是输入passwrod,当然需要验证,也就是同存储的文件当中的信息进行比较,在这个程序当中我需要设置两个选择,就是可以与存储的文件当中的信息进行比较,也可以更改当中的信息,也就是write来实现,我现在有个半成品,实在不知道如何继续,请大家指教
#include <stdio.h>
#include <stdlib.h>

char Menu(void);

void main(void)
{
FILE *fp;
char i,c,co,c1;
char choice;

printf(" Now There Are 2 Possible Choices\n");
printf("1.Enter The Password and Unlock The Door\n");
printf("2.Change Your Password\n");
printf(" Enter Choice:");
scanf("%d",&choice);
fflush(stdin);

switch(choice)
{
case '1':printf("Enter The Password and Unlock The Door:\n");
scanf("%c",&c1);
if (c1 = c)
{
printf("Welcome!!!");
}//end if
else
{
for(i=1;i<=5;i++)
{
fflush(stdin);
printf("Your Passord Is Wrong!Please ReEnter:");
scanf("&c",c1);
}//end for
}//end else
printf("Sorry!You Are Not Allowed To Enter The Room!\n");
case '2':printf("Enter the old password first:");
scanf("%c",c1);
if(c = c1)
{
do{
fp = fopen("C:\\Record.txt","w");
printf("Enter the new password you want to change!");
printf("Password:");
c = getchar();
fflush(stdin);
printf("Confirm:");
co = getchar();
fflush(stdin);
if (c != co)
printf("Different input!Please try Again!\n");
}while(c != co);//end do while
fprintf(fp,"%c\n",co);
fclose(fp);//close the file

printf("Data has been written to the file'C:\\Record.txt'.\n");
printf("Please Remember your password!\n");
}//end if
else
printf("Wrong password,Byebye!");

}//end switch

}//end main

楼主,你的c,c1是干什么的啊,密码不是字符串么,用char怎么行?

大哥,强烈建义用XML来存放