C++ Program to count number of words in a text file

How to write Program to count number of words in a text file in C++ Programming.


C++ Program to count number of words in a text file
C++ Program to count number of words in a text file


Solution:
//Program to count number of words in a text file.
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();

char a[80];
int count=0;
ifstream ifile("out.txt");
while(!ifile.eof())
{
ifile>>a;
count++;
}
cout<<endl<<"Number of words in the file out.txt: "<<count;
getch();
}

.This C++ Program to count number of words in a text file


Learn More :