Hi, i'm trying to compare two text files..one is a user created file and it needs to be compared with a dictionary file. It is then supposed to output which word if any is spelled wrong and display which line number. Can someone guide me in what to do, and maybe supply me some code? thanks!
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
bool word_search(string, string);
bool bad_word(string, int, ostream&);
int main(){
ifstream ins;
ofstream outs;
string outFile;
string inFile;
string line;
int lineCount;
lineCount = 0;
cout << "Please enter an output filename: ";
cin >> outFile;
cout << "Please enter an input dictionary file: ";
cin >> inFile;
word_search(outFile, inFile);
return 0;
}
bool word_search(string out, string in){
ifstream ins;
ifstream ins2;
ofstream outs;
ofstream outs2;
string line;
int lineCount;
lineCount = 0;
ins.open(in.c_str());
if(ins.fail()){
cout << "***Error: Cannot open " << in
<< " for input." << endl;
return EXIT_FAILURE;
}
ins2.open(out.c_str());
if(ins2.fail()){
cout << "***Error: Cannot open " << out
<< " for output." << endl;
return EXIT_FAILURE;
}
getline(ins, line);
while(!ins.eof()){
lineCount++;
cout << line << endl;
outs << line << endl;
getline(ins, line);
}
getline(ins2, line);
while(!ins2.eof()){
lineCount++;
cout << line << endl;
outs2 << line << endl;
getline(ins2, line);
}
return 0;
}