Created
March 5, 2013 04:29
-
-
Save Battleroid/5088013 to your computer and use it in GitHub Desktop.
Continually asks for password until the correct answer is entered.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main () { | |
string passcode = "123"; | |
string guess; | |
bool correct = false; | |
do { | |
cout << "Enter password: "; | |
cin >> guess; | |
if (guess.compare(passcode) != 0) { | |
cout << "Incorrect. Try again." << endl; | |
} else { | |
cout << "Correct!" << endl; | |
correct = true; | |
} | |
} while (!correct); | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment