该楼层疑似违规已被系统折叠隐藏此楼查看此楼
/*--------实现密码的隐式输入-----------------*/
inputpw(char*password,intlen)/*len为密码长度*/
{
inti=0;/*密码数组索引值,同时也表示记录已显示*的数目*/
charch;
fflush(stdin);/*清洗流,以防妨碍密码正确输入*/
for(ch=getch();ch!=13;ch=getch())/*若输入回车则结束密码输入*/
{
if(i>=len)continue;/*如果已到达len指定的长度*/
if(ch==8)/*若按了退格键*/
{
if(i>0)/*如果已显示星数不为0*/
{
printf("\b");
password[--i]='\0';/*password[i-1]的值改为'\0',已显示星数减一,数组索引值减一*/
}
putchar(0);/*显示空字符*/
printf("\b");
continue;
}
if(ch<32||ch>127)continue;/*密码只能为ASCII码值为32-127的字符*/
printf("*");/*上述情况都不是则显示一个星*/
password[i++]=ch;/*将ch赋给password[i],已显示星数加一,数组索引值加一*/
}
password[i]='\0';/*设置结尾的空字符*/
}
/*--------------管理员登录验证,返回登录状态------------------------*/
intlogin(intx)/*x传入第几次登录*/
{
charpws[15],admin[]={"dfghjfgfdg"};/*密码设定,未加密*/
clrscr();
if(x==2)
printf("Inputthepasswordplease:");
else
printf("ThepasswordyouinputisERROR!pleaseinputagain:");
inputpw(pws,15);
printf("\nSystemischeckingyourstatus,pleasewait...");
sleep(2);
if(strcmp(pws,admin)==0){
returnTRUE;}
else
returnFALSE;
}
如果觉得《如何用c语言编辑盗号 想程序高手求助--用C语言来编辑一个输入密码的程序》对你有帮助,请点赞、收藏,并留下你的观点哦!