-
C++ Password mask
I just started messing around with making a password on a simple program. Can anyone here tell me how to, and explain, how to make asterisks appear when the user is enter the password? I searched a little but the few results i found, I didn't completely understand. Thanks
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str1 = "suzuki";
string password ;
do{
cout << "Enter Password\n";
getline(cin, password);
if(password != str1)
{
cout << "Error, try again\n";
}
}
while(password != str1);
int num1, num2;
cout << "Enter a number to add\n";
cin >> num1;
cout << "Enter a nother num\n";
cin >> num2;
cout << " Total is " << num1 + num2 << endl;
system("pause");
return 0;
}
-
You won't be able to use standard cin/cout to mask input. On a quick search it looks like you may need to use the C function getch(). Search for "c++ mask input", and there are plenty of results with people asking for the same thing.
-
As neandrake says, there is nothing standard to help you do this.
So you need to find some function which is specific to your OS/Compiler to do this.