fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. bool isValidPassword(const string &input){
  6. const string password = "banana apes";
  7. return input == password;
  8. }
  9.  
  10. int main(){
  11. string userInput;
  12. cout << "Enter password: " << endl;
  13. getline(cin, userInput);
  14.  
  15. bool result = isValidPassword(userInput);
  16. cout << "The password is " << (result?"":"in") << "valid." << endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 3276KB
stdin
banana apes not
stdout
Enter password: 
The password is invalid.