I have a text file with this format:
user1;password1;user2;password2;user3;password3;user4;password4;user5;password5;user6;password6;user7;password7;user8;password8;user9;password9
And im trying to make a funtion to read the contents of that file, and validate if, first, an user exists in the file, and second, if the password corresponds to that user. All that to make a log in function.
This is what if code until now, and I believe it should work
bool valid_usr_pass(string user,string pass,ifstream& is)
{
string str;
while(!is.eof())
{
getline(is,str,';');
if(user==str)
{
getline(is,str,';');
if(pass==str)
return true;
return false;
}
getline(is,str,';');
}
is.seekg (0, is.beg);
return false;
}
But when i call this function in the main and run the program, it starts to think and think, and it never stops and shows no information in the screen.
Can you tell me please why is not my function working, or if there is another (better) way to do what I'm trying to do? Thank You!