Heres the code i have so far, seems like i just keep doing circles when trying to make this work, but before i post the code the thing im trying to do is be able to call a file from the main function into my void function so i can run getline, find, and string functions on it. I have tried several ways but it doesnt seem to be working at all and i get different errors everytime.
CODE
#include <iostream> // For cin, cout, etc.
#include <fstream> // For File input, output, etc.
#include <iomanip> // For setprecision and setw
#include <string> // For C++ string
using namespace std;
void scanner1(); // Void Functions for spam scanner
void scanner2();
void scanner3();
int main ()
{
string name1;
string name2;
string spam1;
string spam2;
string spam3;
cout<< "MAIN: Please enter the name of the filter file:"; //Calling File with Filter Data
cin>> name1;
cout<< endl;
ifstream fin1(name1.c_str() );
cout<< "MAIN: Please enter the name of the mail file:"; //Calling File with Mail Data
cin>> name2;
cout<< endl;
ifstream fin2(name2.c_str() );
cout<< "MAIN: About to call the scanfile function..."<< endl; //Prompt letting user know function is about to run
fin1>> spam1;
fin1>> spam2;
fin1>> spam3;
scanner1(string);//Void Functions that contains spam scanner
scanner2(string);
scanner3(string);
return 0;
}
void scanner1 (string spam1) //Spam scanner
{
ifstream fin2(name2.c_str() );
cout<< "SCANFILE FUNCTION: Searching "<< name2<< " for the word "<< spam1<< "..."<< endl; //Search Mail Data for 1st group of spam data
return;
}
void scanner2 (string name2, string spam2)
{
string name1;
ifstream fin1(name1.c_str() ); //Reopening Files
ifstream fin2(name2.c_str() );
//Declaring all needed variables
fin1.ignore(265, '/n'); //Skipping 1st line of spam word(s)/phrase(s) in the stream
fin1>> spam2; //Inputing spam word(s)/phrase(s) into stream
cout<< "SCANFILE FUNCTION: Seaching "<< name2<< " for the word "<< spam2<< "..."<< endl; //Search Mail Data for 2nd group of spam data
}
void scanner3 (string name2, string spam3)
{
string name1;
ifstream fin1(name1.c_str() ); //Reopening Files
ifstream fin2(name2.c_str() );
//Declaring all needed variables
fin1.ignore(265, '/n'); //Skipping 1st line of spam word(s)/phrase(s) in the stream
fin1.ignore(265, '/n'); //Skipping 2nd line of spam word(s)/phrase(s) in the stream
fin1>> spam3; //Inputing spam word(s)/phrase(s) into stream
cout<< "SCANFILE FUNCTION: Searching "<< name2<< " for the word "<< spam3<< "..."<< endl; //Search Mail Data for 3rd group of spam data
}
and here is what my output is supposed to resemble...if im asking for to much help just let me know then possibly give me some guidelines on how to fix my problem
MAIN: Please enter the name of the filter file:filter.txt
MAIN: Please enter the name of the mail file:mail.txt
MAIN: About to call the scanfile function...
SCANFILE FUNCTION: Searching mail.txt for the word offer...
Line # Position
1 -1
2 -1
3 -1
4 -1
5 7
SCANFILE FUNCTION: Searching mail.txt for the word mortgage...
Line # Position
1 -1
2 -1
3 -1
4 -1
5 -1
SCANFILE FUNCTION: Searching mail.txt for the word drugstore@spamsender.net...
Line # Position
1 6
2 -1
3 -1
4 -1
5 -1
Press any key to continue . . .