怎么样输入密码时显示*号(在C++中)
来源:百度知道 编辑:UC知道 时间:2024/09/28 06:45:45
是程序题,请高手帮忙
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{char psw[50];
int k=0;
cout<<"Enter password:\n";
while(1){
psw[k]=getch();
if(psw[k]=='\xD')
{psw[k]='\0';break;}
k++;
cout<<"*";
}
if(strcmp("admin",psw)==0)
cout<<"\nRight password!\n";
else cout<<"\nInvalid password!\n";
system("pause");
return 0;
}