and I want to compare each character in a word from that vector of strings.
how can I do that?
For example:
1 2 3 4 5
vector<string> words;
for (int i = 0; i < words.size(); i++)
{
if(words[i] == 'A')
}
Now I know this doesn't work because I can't compare a string to a char. But I want to loop through the characters of a word[i] and compare it to a char.
// http://www.stroustrup.com/C++11FAQ.html#forfor( const std::string& str : words ) // for each string in the vector 'words'
{
for( char c : str ) // for each char in the string
{
if( c == 'A' )
{
// do some thing
}
}
}