int CountChars( apstring str, char ch )
{
int count = 0;
int i;
for( i = 0; i < str.length( ); i++ )
{
if( str[ i ] == ch )
count++;
}
return count;
}
2. The simplest solution is:
int CountChars2( apstring source, apstring target )
{
int count = 0;
int t; // t so that I remember to index target
for( t = 0; t < target.length( ); t++ )
count += CountChars( source, target[ t ] );
return count;
}