求助c语言怎样让输入的密码可回删,已经变成星号了
#include<stdio.h>#include<string.h>
#include<conio.h>
void main()
{
//char name代表用户名 mm代表登陆密码 a代表输入的密码
char name[20], mm[3]={'y','a','n'},a[6];
int i,g;
printf("\n\n\n\t\t\tStudent Manager");
for(i=0;i<3;i++)
{ printf("\n\n\t\tUser Name:");
scanf("%s",&name);
if(strcmp(name,"grace")==0)
{ printf("\t\tPlease input your password:");
for(g=0;g<6;g++)
{
a[g] = getch(); /*逐次赋值,但不回显*/
if (a[g] == '\x0d')/*回车则终止循环*/
{
a[g]='\0';
break;
}
printf("*"); /*以星号代替字符个数*/
}
break;}
else
{
printf("\t\tThe wrong user");
}
}
}