UBER_SPIZZ
UBER_SPIZZ

Reputation: 9

why cant i search for a word in my text file?

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

Answers (1)

Tanveer Badar
Tanveer Badar

Reputation: 5523

You are not comparing the return value of find with string::npos. find does not return a boolean.

Upvotes: 1

Related Questions