Alright, I have some questions.
1. This code does make some sense right?
2. I keep getting my failure to open file message, did I make the program do that or are my test files just not working?
3. How do I make the program acknowledge - and + as characters when sorting through the characters?
/*------------------------------------------------------------------------------*/
/* Page177 Problem12 */
/* */
/* This program will filter data and point out and tally any non-integer, */
/* - sign, or + sign characters. */
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
// Declare objects.
ifstream datain;
string filename;
ofstream dataout;
double mistakes(0), t;
// Ask user for file name.
cout << "Please enter the name of the file you want filtered." << endl;
cin >> filename;
// Assign datin a file
datain.open(filename.c_str());
// Check for opening errors
if (datain.fail())
{
cerr << "Sorry, the file could not be opened properly.";
}
while(!datain.eof())
{
datain >> t;
if( (t=0) || (t=1) || (t=2) || (t=3) || (t=4) || (t=6) || (t=7)
|| (t=8) || (t=9))
{ dataout << t; }
else
{
++mistakes;
dataout << "Illegal character " << t << "found.";
}
}
dataout << "There were " << mistakes << " illegal characters found.";
}