关于登陆密码问题

tuoluofu tuoluofu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我把密码改为*之后就两次输入密码不一致了,请问为什么?

#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
int x=0;//人的编号
int y=0;//书的编号
typedef struct user
{
int ID;//用户编号
char name[11];//用户姓名
char password[10];//用户密码
int store;//记录用户借阅图书数量
int B_id[5];//书的ID
float money;//用户帐户
};
user person[30];
user admin={0,"admin","001"};
typedef struct book
{
int ID;//书编号
char name[21];//书名
char author[11];//作者
int year;//记录图书出版年份
int total;//图书总数
int store;//记录本类图书借出的数量

};
book books[100];
//////////////////////////////////////////////////////////
void indix();
int start();
void password();
void checkin();
///////////////////////////////////////////////////////////
void main()
{
int s;
int i;
while(1)
{

indix();
s=start();
while(1)
{
if(s==1)
{
system("cls");
checkin();

printf("\n\n\n\t\t\t\t注册成功!!!\n\n");
system("pause");
break;
//password() ;
}
else if(s==2)
{

break;
}
else if(s==3)
{
for(i=0;i<3;i++)
{
printf("%d\n%s\n%s\n%d\n%d\n%.2f",person[i].ID,person[i].name,person[i].password,person[i].store,person[i].B_id[i],person[i].money);
printf("\n\n\n");
}
}
else
{
break;
}
}
}
}
void indix()
{
printf("\n\n\n\n");
printf("\t\t\t★☆★☆★★☆★☆★☆★☆★☆★☆★☆★\n");
printf("\t\t\t★☆ * ☆★\n");
printf("\t\t\t★☆ ☆ ☆★\n");
printf("\t\t\t★☆ * ☆★\n");
printf("\t\t\t★☆ 图书馆欢迎您! ☆★\n");
printf("\t\t\t★☆ ☆ ☆★\n");
printf("\t\t\t★☆ *       ☆★\n");
printf("\t\t\t★☆ ☆   ☆★\n");
printf("\t\t\t★☆ *    ☆★\n");
printf("\t\t\t★☆★☆★★☆★☆★☆★☆★☆★☆★☆★\n");
printf("\n\n\n\n");
printf("\t\t\t1.注册\n");
printf("\t\t\t2.登陆\n");
printf("\t\t\t3.退出\n\n\n\n");
}
int start()
{
char s[10];
scanf("%s",&s);
if(strcmp(s,"1")==0)
return(1);
else
{
if(strcmp(s,"2")==0)
return(2);
else
{
if(strcmp(s,"3")==0)
return(3);
else
{
return(0);
}

}
}
}
void checkin()//注册
{

int i;

int re;//记录两次密码验证的值
char pwd_temp[20];//记录临时的密码
//users user_temp;
printf("\n\n\n\t\t\t\t欢迎您的加入!!\n\n:");
printf("\n\n\n\t\t\t\t请输入用户名:");
scanf("%s",person[x].name);
do
{
printf("\n\n\t\t\t\t请输入用户密码:");
for(i=0;i<=8;i++)
{
person[x].password[10]=getch();
if(person[x].password[10]=='\r')
{
person[x].password[10]='\0';
break;

}
else
{
printf("*");
}

}
printf("\n\n\t\t\t\t请再次输入密码:");
for(i=0;i<=8;i++)
{
pwd_temp[10]=getch();
if(pwd_temp[10]=='\r')
{
pwd_temp[10]='\0';
break;

}
else
{
printf("*");
}

}
printf("\nps=%s\n",person[x].password);
//printf("ps=%s\n",pwd_temp);
re=strcmp(person[x].password,pwd_temp);
if(re!=0)
printf("\n\n\t\t\t两次密码不一致,请重新输入!!!\n");

}while(re!=0);
printf("\n\n\t\t\t\t请输入您的注册资金:");
scanf(" %f",&(person[x].money));
person[x].ID=(x+1);
person[x].store=0;
for(i=0;i<5;i++)
{
person[x].B_id[i]=0;
}

}
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
tuoluofu
C语言 70,040 成员 243,237 内容