Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4.  
  5. using namespace std;
  6.  
  7. class PasswordInput
  8. {
  9. private:
  10. string password; /* The string to store the password */
  11. public:
  12. /* string passed to it will be the actual password */
  13. PasswordInput(string pass) : password(pass) { }
  14. void Input() /* Get the password from the user */
  15. {
  16. string input; /* The string to store the input */
  17. while (true) /* Infinite loop until RETURN is pressed */
  18. {
  19. char temp;
  20. temp = getch(); /* wait for user input a character */
  21. /* check if it return was pressed, if so exit the loop */
  22. if (GetAsyncKeyState(VK_RETURN))
  23. break;
  24. input += temp;
  25. cout << '*';
  26. }
  27. if (password==input) /* If they match, user could gain access to something */
  28. cout << "\nThat's correct!";
  29. else /* Otherwise, tell them it's wrong */
  30. cout << "\nThat's wrong!";
  31. }
  32. };
  33.  
  34. int main()
  35. {
  36. PasswordInput pass("passme");
  37. pass.Input(); /* Get the input from the user and compare if it's the password */
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement