#include "stdio.h"
#include "conio.h"
int main (void)
{
char a[6];
int i;
int num = 0;
printf ("请输入六位数密码\n");
while (num<6){
for (i=0;i>=0;i++)
{
a[i]=getch ();//输入密码
if (a[i]>32&&a[i]<127) //支持范围
{printf ("*");//显示* num++;}
else if (a[i]==13) //回车跳出 break;
else if (a[i]==8) {i-=2;putchar ('\b');
putchar (' ');putchar ('\b');//
}
else i--;
if (i>5&&a[i]!=8)
{putchar ('\b');putchar (' ');putchar ('\b');break;}
}
if (num<6) printf ("请重新输入!\n");
}
printf ("\n您输入的密码是\n");
for (i=0;i<6;i++) printf ("%c",a[i]);//回显密码
getchar ();
return 0;
}
#include "conio.h"
int main (void)
{
char a[6];
int i;
int num = 0;
printf ("请输入六位数密码\n");
while (num<6){
for (i=0;i>=0;i++)
{
a[i]=getch ();//输入密码
if (a[i]>32&&a[i]<127) //支持范围
{printf ("*");//显示* num++;}
else if (a[i]==13) //回车跳出 break;
else if (a[i]==8) {i-=2;putchar ('\b');
putchar (' ');putchar ('\b');//
}
else i--;
if (i>5&&a[i]!=8)
{putchar ('\b');putchar (' ');putchar ('\b');break;}
}
if (num<6) printf ("请重新输入!\n");
}
printf ("\n您输入的密码是\n");
for (i=0;i<6;i++) printf ("%c",a[i]);//回显密码
getchar ();
return 0;
}