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 un, string pw)
- {
- string login_username, login_password;
- //un, pw;
- cout << "Unesite username: "; cin >> login_username;
- cout << "Unesite password: "; cin >> login_password;
- ifstream read("d:\\" + login_username + ".txt");
- string iscitani_us, iscitani_pw;
- getline(read, iscitani_us);
- getline(read, iscitani_pw);
- if (iscitani_us == login_username && iscitani_pw == login_password )
- return true;
- else
- return false;
- }
- int main()
- {
- int choice;
- cout << "1: Registracija\n2: Login\nIzbornik: "; cin >> choice;
- if (choice == 1)
- {
- string username, age, password;
- cout << "Izaberite Zeljeni UserName: "; cin >> username;
- cout << "Izaberite Zeljene godine: "; cin >> age;
- cout << "Izaberite Zeljenu Lozinku: "; cin >> password;
- ofstream file;
- file.open("d:\\" + username + ".txt");
- file << username;
- file << endl;
- file << password;
- file.close();
- }
- else if (choice == 2)
- {
- string user, pass;
- cout << "Izaberite Zeljeni UserName: "; cin >> user;
- cout << "Izaberite Zeljenu Lozinku: "; cin >> pass;
- bool status = IsLoggedIn(user, pass);
- if (!status)
- {
- cout << "[ERROR]" << endl;
- system("COLOR 4f");
- system("PAUSE");
- return 1;
- }
- else
- {
- cout << "[USPIJESNO]" << endl;
- system("COLOR 2f");
- system("PAUSE");
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement