c语言密码登陆退格问题?按退格键还是显示“*”
#include"stdio.h"#include"conio.h"main(){charqq[12],zqq[12],passw[16],zpassw[16],ch;i...
#include"stdio.h"
#include"conio.h"
main()
{
char qq[12],zqq[12],passw[16],zpassw[16],ch;
int k,i;
/*注册部分*/
printf("please registration account:");
gets(zqq);
printf("please input you password:");
i=0 ;
while((ch=getch())!='\r')
{
zpassw[i++]=ch;
putchar('*');
}
zpassw[i]='\0';
printf("\n");
system("pause");
clrscr();
/*登陆部分*/
for(k=1;k<=3;k++)
{
printf("please input qq:");
i=0;
gets(qq);
printf("please input password:");
while((ch=getch())!='\r')
{
passw[i++]=ch;
putchar('*');
passw[i]='\0';
}
sleep(1);
if(strcmp(qq,zqq)!=0)
{
printf("\nqq is error \n");
if(k<=2)
printf("you have %d chance\n",3-k);
else
{
printf("\ngame over!!!");
sleep(2);
exit(1);
}
}
else if(strcmp(passw,zpassw)==0)
{
printf("\nwelcome!!!\n");
break;
}
else
{
printf("\nyou password is error!!!");
if(k<=2)
printf("\nyou have %d chance\n",3-k);
else
{
printf("\ngame over!!!\n");
sleep(2);
exit(1);
}
}
}
getch();
} 展开
#include"conio.h"
main()
{
char qq[12],zqq[12],passw[16],zpassw[16],ch;
int k,i;
/*注册部分*/
printf("please registration account:");
gets(zqq);
printf("please input you password:");
i=0 ;
while((ch=getch())!='\r')
{
zpassw[i++]=ch;
putchar('*');
}
zpassw[i]='\0';
printf("\n");
system("pause");
clrscr();
/*登陆部分*/
for(k=1;k<=3;k++)
{
printf("please input qq:");
i=0;
gets(qq);
printf("please input password:");
while((ch=getch())!='\r')
{
passw[i++]=ch;
putchar('*');
passw[i]='\0';
}
sleep(1);
if(strcmp(qq,zqq)!=0)
{
printf("\nqq is error \n");
if(k<=2)
printf("you have %d chance\n",3-k);
else
{
printf("\ngame over!!!");
sleep(2);
exit(1);
}
}
else if(strcmp(passw,zpassw)==0)
{
printf("\nwelcome!!!\n");
break;
}
else
{
printf("\nyou password is error!!!");
if(k<=2)
printf("\nyou have %d chance\n",3-k);
else
{
printf("\ngame over!!!\n");
sleep(2);
exit(1);
}
}
}
getch();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询