#include <fstream>
#include <sstream>
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char ch, word=' ';
int ch_cnt=0, space_cnt=0, word_cnt=0;
//if( word >>'a');
//word_cnt--;
ifstream inFile; // Identify the file
string path;
cout<< "Enter the location of the file.";
cin>> path;
inFile.open("path");
// Associate the file name with a physical
// file on the disk.
if( inFile.fail() )
{
cout<<"Either you or the machine are having issues! The test results have\n"
"determinded that you are the error.\n";
getch();
exit(1);
}
// If we get here, the file is open
// THE BATCH PROCESSING LOOP
ch = inFile.get(); // Read
while( !inFile.eof() ) //Test for end of file
{
cout<<ch; // Process
ch_cnt++;
if( isspace(ch))
space_cnt++;
if( !isspace(word)&& isspace(ch))
word_cnt++;
word=ch;
ch=inFile.get(); //Read
}
if(!isspace(word))
word_cnt++;
cout<<"\n\n|"<<word<<"|\n\n";
cout<<"\n The character count is "<<ch_cnt;
cout<<"\n \n The space count is "<<space_cnt;
cout<<"\n \n The word count is "<<word_cnt;
inFile.close();
cout<<"\n\nNormal termination.\n";
getch();
return 0;
}