Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- bool IsLoggedIn()
- {
- string username, password, un, pw;
- cout << "Enter username: ";
- cin >> username;
- cout << "Enter Password: ";
- cin >> password;
- ifstream read("D:\\C++\\Console\\Users\\Users.txt");
- getline(read, un);
- getline(read, pw);
- if (un == username && pw == password)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- int main()
- {
- int choice;
- cout << "1: Register\n2: Login\nYour choice: "; cin >> choice;
- if (choice == 1)
- {
- string username, password;
- cout << "select a username: "; cin >> username;
- cout << "select a password: "; cin >> password;
- ofstream file;
- file.open("D:\\C++\\Console\\Users\\Users.txt");
- file << username << " : " << password << "\r";
- file.close();
- main();
- }
- else if (choice == 2)
- {
- bool status = IsLoggedIn();
- if (!status)
- {
- cout << "False Login!" << endl;
- system("PAUSE");
- return 0;
- }
- else
- {
- cout << "Succesfully loggin in!" << endl;
- system("PAUSE");
- return 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement