/*
Write a program to read a character C and then a string S and to
display how many times C appears in S.
This program does not takes case into account (i.e. it's case insensitive).
It's with repetition.
*/

#include <iostream>
#include <string>
using namespace std;
int main()
{
        string s;
        char c;
        int i, count;
		char repeat = 'Y';
		while (toupper(repeat) == 'Y')
		{
			system("cls");
			count = 0;
			cout << "Enter a string: " << endl;
			cin >> s;
			cout << "Enter a character: " << endl;
			cin >> c;
			for (i = 0; i < s.size(); i++)
                if (tolower(s[i]) == tolower(c))
                        count++;
			cout << c << " appears in the input: "
				<< count << " times.\n";
			cout << "To continue, press 'y' or 'Y': " << endl;
			cin >> repeat;
		}
        return 0;
}

