#include <iostream>
#include <string>
usingnamespace std;
int numOfChar(string text, char letter)
{
int numOfChar = 0;
for (int i = 0; i < text.length(); i++)
{
if (text[i] == letter)
{
numOfChar++;
}
}
return numOfChar;
}
int main()
{
string text;
char letter;
int Result = 0; // number of same letter in a word
cout << "ENTER LETTER: ";
cin >> letter;
cout << "ENTER TEXT: ";
cin >> text;
//covert letter to capital for better comparison
letter = toupper(letter);
//convert all of the string to capital for better comparison
for (unsignedint i = 0; i < text.size(); i++)
{
text[i] == toupper(i);
}
Result = numOfChar(text, letter);
cout << "THE NUMBER OF SAME LETTERS IN A WORD IS " << Result << endl;
system("PAUSE");
return 0;
}