Hey, I'm trying to compare a std::string with a string out of an array. Somehow it doesn't work.
The User types in a word in the main method and it gets delivered to my search method as keyword.
in the search function i have my stringarray with words. If my keyword matches with one of the words in the array, the method shall return true; else false.
The User types in a word in the main method and it gets delivered to my search method as keyword.
in the search function i have my stringarray with words. If my keyword matches with one of the words in the array, the method shall return true; else false.
Code:
bool serach(string keyword){
bool found = false;
int index;
//Archive//
string words[] = { "msg", "chrome","steam","spotify","discord" };
//-----// Searching for Input //-----//
for (int i = 0; i < sizeof(words); i++) {
if (words[i] == keyword) {
cout << "found";
getchar();
return true;
}
if (!found == false && i == sizeof(words)) {
return false;
}
}