Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. char username[30];
  5. char password[30];
  6. char userinputname[30];
  7. char userinputpass[30];
  8.  
  9. using namespace std;
  10.  
  11. void registeruser () {
  12.  
  13.     cout << "Desired username (only up to 30 characters): ";
  14.     cin >> username;
  15.     cout << "\n\n";
  16.  
  17.     cout << "Desired password (only up to 30 characters): ";
  18.     cin >> password;
  19.  
  20. }
  21.  
  22. void login () {
  23.  
  24.     cout << "Username: ";
  25.     cin >> userinputname;
  26.     cout << "\n\n";
  27.  
  28.     cout << "Password: ";
  29.     cin >> userinputpass;
  30.     cout << "\n\n";
  31.  
  32.     if (userinputname == username && userinputpass == password)  {
  33.  
  34.         cout << "Login success!";
  35.  
  36.     }
  37.  
  38.     else {
  39.  
  40.         cout << "Login failure.";
  41.  
  42.     }
  43.  
  44. }
  45.  
  46. int main () {
  47.  
  48.     string answer;
  49.  
  50.     cout << "Hello, and welcome to login v1.0\n\n";
  51.  
  52.     cout << "Do you have an account yet: ";
  53.     cin >> answer;
  54.  
  55.     if (answer ==  "yes") {
  56.  
  57.         login();
  58.  
  59.     }
  60.  
  61.     else if (answer == "no") {
  62.  
  63.         registeruser();
  64.         cout << "\n\n";
  65.         login();
  66.  
  67.     }
  68.  
  69.     cin.get();
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement