void login()//登录账号
{
FILE *fp;
struct land;
int temp3,i=2;
char *temp4[20];
int p_id;
int hit;
char password[20];
do
{
printf("\n请输入学号:");
scanf("%d",&temp3);
printf("\n确认输入请按回车,重新输入请按ESC!");
hit=getch();
for (;hit!=13&&hit!=27;)//保证只能是CR和ESC才能退出循环,输入其他字符无用,暂停程序,按'CR'继续。
{
hit=getch();
}
}
while(hit==27);
printf("\n请输入密码:");
scanf("%s",temp4);
if ((fp=fopen("land.txt","r"))==NULL)
{
printf("\n 还未存在用户,请注册账户!");
system("pause");system("cls");main();
}
for(;!feof(fp);)
{
fscanf(fp,"%d%s",&p_id,&password);
if(temp3==p_id)
{
if(strcmp(*temp4,password)==0)
{
printf("\n登陆成功,按任意键继续!");
system("pause");u_menu();
}
else
{
printf("\n密码错误,请重新输入:");
system("pause");system("cls");login();
}
}
}
printf("\n用户不存在!");
system("pause");system("cls");main();
}
错误信息:
刚入门,写一个图书管理系统,请大家指教。land.txt是账号密码数据文件。注册完信息之后,跳转到这里登录,输入密码之后程序就不能继续像下运行了求指教。
感谢各位乐于助人的大佬。