I am trying to read a string from a file and compare it to another string. For some reason getline just returns and empty line.
int count =0;
string line;
ifstream emailFile;
emailFile.open("email.txt");
if (emailFile.is_open())
{
cout << "file open \n";
while (emailFile.eof()!=true)
{
getline(emailFile,line);
cout <<line<<endl;
for (int i=0; i<27; i++)
{
cout <<"line: "<< line << endl;
cout<< "Spamword: "<< spamWords[i]<<endl;
if (line.find(spamWords[i]) != string::npos)
{
cout <<"found line: "<< line << endl;
cout<< "found Spamword: "<< spamWords[i]<<endl;
count +=2;
}
}
}
}
else cout<< "file not found";
cout <<count;
}
I have tried troubleshooting it and I really don't see why nothing is being read.
Any help would be appreciated.