Verzingz

Learn C++

Jun 10th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #include <iostream> /* Includes different resources to be used in the program */
  2. #include <string>
  3.  
  4. using namespace std; /* Removes the std:: so it can just be cout not std::cout */
  5.  
  6. void update() { /* A function */
  7. system("CLS"); /* Clears console */
  8. }
  9.  
  10. int main(int agrv, char** argc) { /* The main function */
  11. update(); /* Calls the update function */
  12.  
  13. string newUsername; /* Strings */
  14. string newPassword;
  15. string username;
  16. string password;
  17.  
  18. std::cout << "New Username: "; /* cout = console output. << is going out so it's output*/
  19. cin >> newUsername; /* cin = console input. >> is going in so it's input */
  20.  
  21. std::cout << "New Password: ";
  22. cin >> newPassword;
  23.  
  24. if (newUsername.length() < 3) { /* If the length of the username is less than 3 do the following */
  25. update();
  26.  
  27. std::cout << "The length of the username cannot be less than 5 characters!" << endl << endl;
  28. std::cout << "[Press Any Key To Continue]";
  29. system("PAUSE >NULL");
  30.  
  31. int main(); /* Calls the main function */
  32. main();
  33. }
  34. else if (newUsername.length() > 20) { /* If the username is above 20 characters, do the following */
  35. std::cout << "The length of the username cannot be above 20 characters!" << endl << endl;
  36. std::cout << "[Press Any Key To Continue]";
  37. system("PAUSE >NULL");
  38. }
  39. else if (newUsername == newPassword || newPassword == newUsername) { /* If newPassword is equal to newUsername, do the following. == is equal to */
  40. int main();
  41. main();
  42. }
  43. else if (newPassword.length() < 5) {
  44. update();
  45.  
  46. std::cout << "The length of the password cannot be less than 5 characters! " << endl;
  47. std::cout << "[Press Any Key To Continue]";
  48. system("PAUSE >NULL");
  49.  
  50. int main();
  51. main();
  52. }
  53.  
  54. update();
  55.  
  56. std::cout << "Plase Login" << endl << endl;
  57.  
  58. std::cout << "Username: ";
  59. cin >> username;
  60.  
  61. std::cout << "Password: ";
  62. cin >> password;
  63.  
  64. if (username != newUsername) { /* If username is not equal to newUsername, != is not equal */
  65. update();
  66.  
  67. std::cout << "Username or password do not math!" << endl;
  68. std::cout << "[Press Any Key To Continue]";
  69. system("PAUSE >NULL");
  70. }
  71. else if (password != newPassword) {
  72. update();
  73.  
  74. std::cout << "Username or password do not math!" << endl;
  75. std::cout << "[Press Any Key To Continue]";
  76. system("PAUSE >NULL");
  77. }
  78.  
  79. update();
  80.  
  81. std::cout << "Successfully logged in as " << username << "!" << endl;
  82. std::cout << "[Press Any Key To Continue]";
  83. system("PAUSE >NULL"); /* Pause the console, >NULL just pauses it without it printing 'Press any key to continue' */
  84.  
  85. return 0; /* Returns a value, 0 as true / no errors, passed :) 1 as it has an error, say if you're checking for a file and it doesn't exist, you'll do 'return 1' */
  86. }
Add Comment
Please, Sign In to add comment