Hey, another question. In this program I'm asking the user to input a word at least 5 characters, then a single character to show how many times it repeats in the world. All though there are no errors while compiling my answer is something drastic. For example, if I entered the word 'hello' then I enter 'l' to see how many times it comes the answer is always between 40-50.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
system("Color A");
string word = "";
do
{
cout << " Enter a word that has at least five characters: \n" << endl;
cin >> word;
} while(word.size() < 5) ;
char searCh = '0';
int counter = '0';
cout << "Enter a character and we'll tell you how many time your character will repeat itself, in the word " << word << "\n" << endl;
cin >> searCh;
for (int i = 0; i < (int)word.size(); i++)
{
char ch = word.at(i);
if (searCh == ch)
{
counter++;
}
}
cout << "The Number of " << searCh << "'s in the word, " << word << " is " << 50 - counter << "." << endl;
system("Color D");
system("PAUSE");
}