How to compare two different data types

I have to compare the contents of a char array to a string. I have to use an if statement to see if one of the characters of the array match one of the letters in the string. How do I go about this?
Do you have to match only character or all of them?
If you have to match only one, use indexes like you do for arrays.
1
2
3
4
if (myString[0] == charArray[0])
{
    //do something
}


Edit: Be sure to not go out of bounds.
This isn't the only way to do it, just the first way I thought of.
Last edited on
char array has characters that the user inputs through some kind of loop. The user is trying to guess a secret word which a string that is a global variable. Its actually the game Hangman. To give you an idea.
First, what forces the use of a char array? One can do input to std::string too.

Second, perhaps: http://www.cplusplus.com/reference/string/string/find_first_of/
Topic archived. No new replies allowed.