Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string setPass(bool show_asterisk = true)
- {
- const char BACKSPACE = 8;//ASCII code for BACKSPACE Key
- const char ENTER = 13;//ASCII code for ENTER Key
- string pass = " ";//initialize string
- char c = ' ';//initialize character
- while ((c = _getch()) != ENTER)
- {
- if (c == BACKSPACE)
- {
- if (pass.length() != 0)
- {
- if (show_asterisk)
- cout << "b b";
- pass.resize(pass.length() - 1); //resize the length of pass
- }
- }
- else if (c == 0 || c == 224)//when player press esc key
- {
- _getch();
- continue;
- }
- else
- {
- pass.push_back(c);
- cout << '*';
- }
- }
- cout << endl;
- return pass;
- }
- cout << "==================" << endl;
- cout << " login " << endl;
- cout << " ID:";
- cin >> id;
- cout << " Password:";
- cin >> pwd;
- pwd = setPass();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement