-
guidence
i`m making a game were the user has to type in there password and instead of seeing the actual password i need to know how to just show the *** sign
just give me a link to a tutorial or something, i`m not asking for help i`m just asking for guidence
-eldian()
-
Here's a quick and dirty way to do it using conio and getch. Substitute your own nonblocking read where appropriate:
Code:
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
static string getPass()
{
string pass;
int i;
int ch;
while ((ch = getch()) != '\r')
{
if (ch == '\b')
cout<<"\b\b \b\b";
pass += (char)ch;
cout.put('*');
}
return pass;
}
int main(void)
{
string password = getPass();
cout<<"\n"<< password <<endl; /* Test print: Does it work? */
return 0;
}