Posts Tagged ‘Write a function to count number of words in a text file named “OUT.TXT”’

Write a function to count number of words in a text file named “OUT.TXT”

February 16th, 2013, posted in C++
Share
void countwords()
{
	ifstream fin;
	fin.open("out.txt");
	char word[30];
	int count=0;
	while(!fin.eof())
	{
		fin>>word;
		count++;
	}
	cout<<"Number of words in file are "<<count;
	fin.close();
}
Share

Write a function to count number of words in a text file named "OUT.TXT"

February 16th, 2013, posted in C++
Share
void countwords()
{
	ifstream fin;
	fin.open("out.txt");
	char word[30];
	int count=0;
	while(!fin.eof())
	{
		fin>>word;
		count++;
	}
	cout<<"Number of words in file are "<<count;
	fin.close();
}
Share