#include <iostream>
#include <conio.h>
using namespace std;
int main() {
fflush(stdin);
cout << "请输入密码:";
int idx = 0;
char password[20], c;
while((c = getch()) != 13) { // 13是回车,8是删除
if(c == 8 && idx > 0) {
printf("\b \b");
idx--;
continue;
}
if(c != 8) {
password[idx++] = c;
putchar('*');
}
}
compare[idx] = '\0';
cout << "\n输入的密码为:" << password<< endl;
return 0;
}
04-30
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交