Reputation: 13
int main() {
int x;
const int Maxword = 5;
std::string Guess[Maxword];
std::string words[Maxword] = {
"Hello",
"World",
"Shift",
"Green",
"Seven"
};
srand(time(NULL));
int iSecret = rand() % 4 + 1;
std::string Cool(words[iSecret]);
for (int i = 0; i < 5; i++) {
std::cout << Cool[i] << std::endl;
}
for (int i = 0; i < 5; i++) {
std::cout << ("Please enter the letters you would like to guess") << std::endl;
std::cin >> Guess[i];
std::cout << Guess[i] << std::endl;
}
for (int i = 0; i < 5; i++) {
if (Guess[i] == Cool[i]) {
std::cout << Guess[i] << "Is in the word";
}
}
For this statement here at the Bottom for statement within the if statement it has a no operator dont mind the actual code it is just a rough draft before I make the actual code but i dont see the problem.
Upvotes: 0
Views: 1292
Reputation: 29266
Cool
is a string. Cool[i]
is a character. Guess
is an array of strings. Guess[i]
is a string. You're trying to compare a character to a string. You probably mean if (guess[i] == Cool)
Upvotes: 1