I don't really get your question
you could save all of the string into a vector rather
than save them into an old style array
Then iterate through all of the string in the vector
//don't pass by value but pass by reference
//remember to add const if you don't want the str to be changed
int numS( string str )
{
int countChar = 0;
for (int i = 0; str[i] != '\0'; i++)
{
if ( str[i] == 's' )
countChar++;
}
return countChar;
}
you could make your life easier by template
template<char ch>
size_t num( std::string const &str )
{
int countChar = 0;
for (int i = 0; str[i] != '\0'; i++)
{
if ( str[i] == ch )
countChar++;
}
return countChar;
}
typedef num<'z'> numZ;
typedef num<'s'> numS;
typedef num<'c'> numC;
I don't know why are you want to design something like numA, numZ and so on
would it better than countChar?