控制台程序输入密码时显示星号

int _tmain(int argc, _TCHAR* argv[]) { char password[100]=""; char c; int i=0; while (true) { c=getch(); if (c=='/r') { break; } else if (c=='/b') { if (i>0) i--; putchar('/b'); putchar(' '); putchar('/b'); } else { password[i++] = c; putchar('*'); } } password[i] = '/0'; cout<<"/n你的密码是:"<<password<<endl; system("pause"); return 0; }  

你可能感兴趣的:(c)