Password and Username

Hello! I made a post before about dialog box in Windows using C++, I deleted it ,I realized how stupid it was. What I want now is to know how to make a program that will ask me for my password and username and if they are correct a folder or something will open. I want to know this for my work, not to copy,to understand ,Thank you.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <string>
using namespace std;

int main(){
    string attempt;   // what the user enters
    string password = "man";  // actual password

    cout << "Enter password (0 to exit) and press ENTER: ";

    while (true){
        getline(cin, attempt);
        cout << endl;
        if (attempt[0] == '0')
            break;
        if (attempt == password){
            cout << "correct!"; // revise to what you want done here, probably call a function
            break;
        }
        else
            cout << "Incorrect, retry (0 to exit): ";
    }
    cin.get();
    return 0;
}
Last edited on
Are you trying to lock a folder down? To do this you would at the very least need access to the ACL's. Even then your settings could be overwritten.
No I don`t want to lock a folder , I just want to enter a password and username and whne they are correct something will pop-up. Thank you For your support!!!
Topic archived. No new replies allowed.