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 <<"Username: ";
- cin>>username;
- cout<<"Password: ";
- cin>>password;
- ifstream read("data\\" + username +".txt");
- getine(read, un);
- getline(read, pw);
- if(un ==username && pw==password)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- int main()
- {
- int choice;
- cout<<"1: Register\n2: Login\nScegli: ";
- cin>>choice;
- if(choice==1)
- {
- string username, password;
- cout<<"Seleziona un username: ";
- cout<<"Seleziona una password: ";
- ofstream file;
- file.open("data\\" + username + ".txt");
- file<<username<<endl<<password;
- file.close();
- main();
- }
- else if(choice==2)
- {
- bool status=IsLoggedIn();
- if(!status)
- {
- cout<<"Login fallito!"<<endl;
- system("PAUSE");
- return 0;
- }
- else
- {
- cout<<"Loggato con successo!"<<endl;
- system("PAUSE");
- return 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement