Reputation: 9
my program takes input from the user and compares it to one of the words in a text file. this was my attempt but permitted_from_database
always returns a true regardless of what the user has typed in.
ifstream database("user_details.txt");
ifstream fin("user_data");
while (getline(database, loginspasswords)) {
if (loginspasswords.find(this_attempt)) {
permitted_from_database = true;
return true;
}
}
return false;
database.close();
}```
Upvotes: 0
Views: 41
Reputation: 5523
You are not comparing the return value of find with string::npos. find does not return a boolean.
Upvotes: 1