/*
The following program reads the name of an input file and then 
it counts the number of semicolons in the file.
 */
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream inputFile;
	string inputFileName;
	char ch;
	int count = 0;
	cout << "Enter the name of the input file: ";
	cin >> inputFileName;
	inputFile.open(inputFileName.c_str());
	if (!inputFile)
	{
		cout << "Can't open the file." << endl;
		return 1;
	}
	inputFile >> ch; // could also use inputFile.get(ch);
	while (inputFile)
	{
		if (ch == ';')
			count++;
		inputFile >> ch; // could also use inputFile.get(ch);
	}
	inputFile.close();
	cout << "The file has " << count << " semicolons."
		<< endl;
	return 0;
}
