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 << "Unesite Username: "; cin >> username;
- cout << "Unesite Password: "; cin >> password;
- ifstream read("d:\\" + username + ".txt");
- getline(read, un);
- getline(read, pw);
- if (un == username && pw == 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();
- main();
- }
- else if (choice == 2)
- {
- bool status = IsLoggedIn();
- 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