Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int main()
- {
- const std::string PASSWORD = "bulletsfordemons";
- const int MAX_TRIES = 5;
- bool login_success = false;
- std::string user_entry;
- int cnt = 0;
- while (login_success == false && cnt < MAX_TRIES)
- {
- std::cout << "Please enter your password: " << std::endl;
- std::cin >> user_entry;
- ++cnt;
- if (user_entry == PASSWORD)
- {
- login_success = true;
- std::cout << "You've entered the correct password. Welcome to the system." << std::endl;
- }
- else
- {
- std::cout << "INCORRECT PASSWORD!" << std::endl;
- }
- }
- if (cnt == MAX_TRIES && !login_success)
- {
- std::cout << "Nice try, but I'm not that easy to crack." << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement