#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
using namespace std;
int main() {
string firstFile, secondFile, temp;
ifstream inFile;
ofstream outFile;
cout << "Enter the name of the input file" << endl;
cin >> firstFile;
cout << "Enter the name of the output file" << endl;
cin >> secondFile;
inFile.open(firstFile.c_str());
outFile.open(secondFile.c_str());
while(inFile.good()) {
getline(inFile, temp, ' ');
if ( temp.substr(0,4) != "-----"
&& temp.substr(0,5) != "HEADER"
&& temp.substr(0,5) != "SUBID#"
&& temp.substr(0,5) != "REPORT"
&& temp.substr(0,3) != "DATE"
&& temp != ""
&& temp != "")
{
outFile << temp;
}
}
inFile.close();
outFile.close();
return 0;
}
Hi All. I'm attempting to output all lines from a text file that do not meet the criteria in the control structure -- i.e. no blank lines, no symbols, etc. However, when I run this code it outputs everything, not taking into consideration my specifc requirements. If anyone could tell me what I'm doing wrong it would be greatly appreciated.