c语言密码登录程序后有其他程序,想程序高手求助--用C语言来编辑一个输入密码的程序...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

/*--------实现密码的隐式输入-----------------*/

inputpw(char *password,int len) /*len为密码长度*/

{

int i=0; /*密码数组索引值,同时也表示记录已显示*的数目*/

char ch;

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'; /*设置结尾的空字符*/

}

/*--------------管理员登录验证,返回登录状态------------------------*/

int login(int x) /*x传入第几次登录*/

{

char pws[15],admin[]={"dfghjfgfdg"}; /*密码设定,未加密*/

clrscr();

if(x == 2)

printf("Input the password please:");

else

printf("The password you input is ERROR!please input again:");

inputpw(pws,15);

printf("\nSystem is checking your status,please wait...");

sleep(2);

if(strcmp(pws,admin)==0){

return TRUE;}

else

return FALSE;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值