I need to pull usernames and passwords from a .txt file and I am having a difficult time wrapping my mind around how exactly to do this. I'll try to break this down.
- Open the file
- Read in the Usernames
- Compare a username against a user input
- Compare a password against a user input associated with the username
- return true or false if the username and passwords match
Yes, this is homework. And I am learning how to use the fstream while waiting for USPS to ship my class txt book. Your help is greatly appreciated!
Here is what I have so far:
bool User::check(const string &uname, const string &pass)
{
//open the file
fstream line;
line.open("users.txt");
//Loop through usernames
//If a username matches, check if the password matches
}
The users.txt file looks like this:
ali87 8422
ricq7 bjk1903
messi buneyinnessi
mike ini99ou
jenny Y00L11A09
end