Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4. bool Login(char username[], char password[]) {
  5. cout << "\t\tPlease Login to you account" << endl;
  6. char* TMP_USER_NAME = (char*)malloc(sizeof(char) * 20);
  7. char* TMP_PASSWORD = (char*)malloc(sizeof(char) * 20);
  8.  
  9. cout << "Enter your username: ";
  10. cin >> TMP_USER_NAME;
  11.  
  12.  
  13. cout << "Enter your password: ";
  14. cin >> TMP_PASSWORD;
  15.  
  16. if (strcmp(username, TMP_USER_NAME) && strcmp(password, TMP_PASSWORD)) {
  17. return false;
  18. }
  19. else
  20. return true;
  21. }
  22.  
  23. char* Change_Password(char password[]) {
  24. char* CURRENT_PASSWORD = (char*)malloc(sizeof(char) * 20);
  25. char* TMP_NEW_PASSWORD = (char*)malloc(sizeof(char) * 20);
  26. char* TMP_CONFIRM_NEW_PASSWORD = (char*)malloc(sizeof(char) * 20);
  27.  
  28. cout << "Enter your old password: ";
  29. cin >> CURRENT_PASSWORD;
  30. if (strcmp(CURRENT_PASSWORD, password)) {
  31. cout << "Enter a new password: ";
  32. cin >> TMP_NEW_PASSWORD;
  33. cout << "Confirm your new password: ";
  34. cin >> TMP_CONFIRM_NEW_PASSWORD;
  35. if (strcmp(TMP_NEW_PASSWORD, TMP_CONFIRM_NEW_PASSWORD)) {
  36. for (int i = 0; i < 20; i++) {
  37. password[i] = TMP_NEW_PASSWORD;
  38. }
  39. }
  40. }
  41. }
  42. int main() {
  43. char Username[20];
  44. char Password[20];
  45. char Email[20];
  46. int input;
  47. cout << "Would you like to login to reset your password?" << endl;
  48. cout << "1) Register " << endl;
  49. cout << "2) Login" << endl;
  50. cout << "3} Change Password" << endl;
  51. cin >> input;
  52. switch (input) {
  53. case 1: {
  54. cout << "Enter your username: ";
  55. cin >> Username;
  56.  
  57. cout << "Enter your password: ";
  58. cin >> Password;
  59.  
  60. cout << "Enter your Email: ";
  61. cin >> Email;
  62.  
  63. }
  64. case 2: {
  65. if (Login(Username, Password)) {
  66. cout << "Login Successful" << endl;
  67. }
  68. else {
  69. cout << "Wrong password or username" << endl;
  70. }
  71. }
  72. case 3:
  73. }
  74.  
  75.  
  76.  
  77. cin.get();
  78. cin.get();
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement