Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct account {
- string login;
- string pass;
- bool admin;
- };
- bool auth() {
- account user;
- account input;
- ifstream fin("users.bin", ios::binary | ios::in);
- if (fin.is_open()) {
- while (true) {
- system("cls");
- cout << "login: ";
- getline(cin, input.login);
- cout << "pass: ";
- getline(cin, input.pass);
- while (!fin.eof()) {
- fin.read((char*)&user, sizeof(user));
- if (input.login == user.login && input.pass == user.pass) {
- fin.close();
- system("cls");
- cout << "hello, " << user.login << "n" << endl;
- cout << "press any key...";
- _getwch();
- return user.admin;
- }
- }
- system("cls");
- cout << "Incorrect login or passwordn" << endl;
- cout << "press any key...";
- _getwch();
- fin.clear();
- fin.seekg(0, ios::beg);
- }
- }
- else {
- cout << "File is not avalible" << endl;
- abort();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement