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.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.