'Need to see if character is in array but not in same position as other array c++
I'm making a wordle in C++ and I need to check two char arrays against each other to see if the letter in one is in the other one but not in the same position, here's my code so far, the second if in the for loop is where I need help (its going to be colored that's the reason for the constants and the color codes):
#include<iostream>
using namespace std;
const string CORRECT = "\033[7;32m";
const string CLOSE = "\033[7;33m";
const string INCORRECT = "\033[7;37m";
const string END = "\033[0m";
int main() {
char word[] = "break";
char guess[] = "water";
char result[5];
string color;
for (int i = 0; i < 5; i++){
if (guess[i] != word[i])
{
color = INCORRECT + guess[i] + END;
result[i] = color
}
if (guess[i] != word[i] && )
{
color = CLOSE + guess[i] + END;
result[i] = color
}
if (guess[i] == word[i])
{
color = CORRECT + guess[i] + END;
result[i] = color
}
}
return 0;
}
I've got it to where it checks to see if its not the same position but I need it to also check for it being elsewhere in the char array. Any help is greatly appreciated, thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
