Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- bool Login(char username[], char password[]) {
- cout << "\t\tPlease Login to you account" << endl;
- char* TMP_USER_NAME = (char*)malloc(sizeof(char) * 20);
- char* TMP_PASSWORD = (char*)malloc(sizeof(char) * 20);
- cout << "Enter your username: ";
- cin >> TMP_USER_NAME;
- cout << "Enter your password: ";
- cin >> TMP_PASSWORD;
- if (strcmp(username, TMP_USER_NAME) && strcmp(password, TMP_PASSWORD)) {
- return false;
- }
- else
- return true;
- }
- char* Change_Password(char password[]) {
- char* CURRENT_PASSWORD = (char*)malloc(sizeof(char) * 20);
- char* TMP_NEW_PASSWORD = (char*)malloc(sizeof(char) * 20);
- char* TMP_CONFIRM_NEW_PASSWORD = (char*)malloc(sizeof(char) * 20);
- cout << "Enter your old password: ";
- cin >> CURRENT_PASSWORD;
- if (strcmp(CURRENT_PASSWORD, password)) {
- cout << "Enter a new password: ";
- cin >> TMP_NEW_PASSWORD;
- cout << "Confirm your new password: ";
- cin >> TMP_CONFIRM_NEW_PASSWORD;
- if (strcmp(TMP_NEW_PASSWORD, TMP_CONFIRM_NEW_PASSWORD)) {
- for (int i = 0; i < 20; i++) {
- password[i] = TMP_NEW_PASSWORD;
- }
- }
- }
- }
- int main() {
- char Username[20];
- char Password[20];
- char Email[20];
- int input;
- cout << "Would you like to login to reset your password?" << endl;
- cout << "1) Register " << endl;
- cout << "2) Login" << endl;
- cout << "3} Change Password" << endl;
- cin >> input;
- switch (input) {
- case 1: {
- cout << "Enter your username: ";
- cin >> Username;
- cout << "Enter your password: ";
- cin >> Password;
- cout << "Enter your Email: ";
- cin >> Email;
- }
- case 2: {
- if (Login(Username, Password)) {
- cout << "Login Successful" << endl;
- }
- else {
- cout << "Wrong password or username" << endl;
- }
- }
- case 3:
- }
- cin.get();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement