Someone please tell me what is wrong with this code:
Code:
#include <fstream>
#include <iostream>
#include <cstdlib>
int main ()
{
using namespace std;
char in_file_name[16], out_file_name[16], next;
int ws, letters;
ifstream fin;
ofstream fout;
cout << "I will find the total number of occurrences of characters in the file "
<< "total number of nonwhitespace characters, and the total number of letters "
<< "in a file\n";
cout << "Enter the input file name (maximum of 15 characters) :\n";
cin >> in_file_name;
cout << "Enter the output file name (maximum of 15 characters) :\n";
cin >> out_file_name;
fin.open(in_file_name);
if (fin.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}
fout.open(out_file_name);
if (fout.fail())
{
cout << "Output file opening failed.\n";
exit(1);
}
fin.get(next);
while (! fin.eof())
{
if (isspace(next))
ws ++;
fin.get(next);
}
fin.get(next);
while (! fin.eof())
{
if (isalpha(next))
letters ++;
fin.get(next);
}
fin.close();
fout.close();
cout << "The total number of whitespaces was " << ws <<endl;
cout << "The total number of letters was " << letters << endl;
cout << "Thank you for using this program\n";
return 0;
}
Code tags added by Kermi3