Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- bool IsSignedIn ()
- {
- string username, password, us, pa;
- cout<<"Enter username:"; cin >> username;
- cout<<"Enter password:"; cin >> password;
- ifstream read("data\\" = username + ".txt");
- getline(read, us);
- getline(read, pa);
- if (un == username && pa == 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("data\\" + username + ".txt");
- file << username << endl << password;
- file.close();
- main();
- }
- else if (choice == 2)
- {
- bool status = IsSignedIn();
- if (!status)
- {
- cout << "Incorrect Login!" << endl;
- system ("PAUSE");
- return 0;
- }
- else
- {
- cout << "Login has been Successful!" << endl;
- system ("PAUSE");
- return 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement