Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <conio.h>
- using namespace std;
- void InputPassword(string &pass) {
- char key;
- do{
- key = getch();
- switch (key) {
- case '\b':
- if(pass.length() > 0) {
- pass.erase(pass.length() - 1, 1);
- cout << '\b' << " " << '\b';
- }
- break;
- default:
- if(key > 31 && key < 127) {
- pass.push_back(key);
- cout << "*";
- }
- }
- }
- while(key != '\r');
- }
- int main(){
- string pass = "";
- string user = "";
- char ch;
- cout << "Enter Username: ";
- cin >> user;
- cout << "Enter Password: ";
- InputPassword(pass);
- if(user == "admin" && pass == "admin")
- cout << "\nAccess Granted :P\n";
- else
- cout << "\nAccess Denied...\n";
- pass = "";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement