First of all it is enough to define either upper case consonants or lower case consonants. To determine whether a character is present in a string you can use function std::strchr
. For example
if ( std::strchr( allConsonants, std::toupper( word ) ) != 0 )
std::cout << word << " is a consonant" << std::endl;
If you know standard algorithms then you can use std::count_if
with a lambda expression to count all consonants in a word.
Last edited on
I'm sure that would work, but it's at a level far above where I'm at. A quick ctrl+f through my textbook shows that lambda expressions and std::strchr functions aren't even covered.
I appreciate the help, either way.
Then why did you use function std::strcmp? If you use function std::strcmp then you may use std::strchr.