I wrote a program that gets the input from user to enter his username and password but what i want is that when user inputs his password it is displayed as ***** and not in english just like when we enter password in Gmail.
I researched on internet and i have managed to write this program but i can't input anything in the password.Also i dont fully understand the code that i have written.
class user
{
private:
string name;
string pass;
public:
void mask()
{
char c;
for(int i=0;i<100;i++)
{
c=getch();
if(c=='\r')
break;
std::cout<<"*";
pass=pass+c;
}
}
void getdata()
{
int flag=0;
do
{
cout<<"Enter username: ";std::getline(std::cin,name);
cout<<endl;
cout<<"Enter password: ";mask();
cout<<endl;
if((name=="myname")&&(pass=="tiger"))
{
cout<<"\n\nLogin successful"<<endl;
flag=1;
}
else
cout<<"\n\nInvalid username or password\n\nHint:Your username and password is myname and tiger"<<endl<<endl;
}while(flag==0);
}
};