954,190 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ Assignment NEED HELP URGENTLY

Guys hello, i`m a new member here [IMG]http://images.devshed.com/fda/smilies/smile.gif[/IMG] Hello to everybody...I need urgently help... I have an assignment for C++.
"We have a collection of emails. This collection has emails from Linguist.org, these mails are legal. these are in a file called ling_filenames.txt. We also have a collection of spam emails in spam_filenames.txt. We have also a file called keywords.txt which has the key words to deside if an email is spam or ling. One word each line. Write a C++ program which checks the email collections and prints:
k1 k2
...
km
...
q1 q2
...
qr
...

This is my code until now....PLEASE HELP ME!!!!!

#include  <iostream> 
#include <set> 
#include <fstream>  
#include <vector> 
#include <string> 
using namespace std;  

string Keys_path="keywords.txt"; 
string ling="ling_filenames.txt";  
string spam="spam_filenames.txt"; 

vector <string> words()  
{ 
vector <string> Keys; 
string word; 
ifstream keysfile  (Keys_path.c_str()); 
while (keysfile>>word) 
Keys.push_back(word);  
return Keys; 
} 

void Check (vector <string> keywords,  string file, int c) 
{ 
void CheckFile(vector <string> Kwords,  string TFile); 
string word; 
int i; 
vector <string> AllFiles;  
ifstream files(file.c_str()); 
while (files>>word)  
AllFiles.push_back(word); 
for (i=0; i<AllFiles.size(); i++) {  
CheckFile(keywords, AllFiles[i]); 
// cout<< 
} 
}  

void CheckFile(vector <string> Kwords, string TFile) 
{ 
set  <string> txt; 
int i; 
string word, a; 
ifstream x  (TFile.c_str()); 
while (x>>word) 
txt.insert(word); 
for(i=0;  i<Kwords.size(); i++) 
{ 
a=Kwords[i]; 
if(txt.find(a)!=txt.end()) {  
cout<<
} 
} 
} 

void CountLines (vector <string>  Kwords, string TFile)
{
set <string> text;
int i;
int  n=0;
ifstream files(ling.c_str());
while (files>>line)  {
AllFiles.push_back(line);
}
for(i=0; i<AllFiles.size();  i++)
n++;
ifstream files2(spam.c_str());
while (files2>>line)  {
AllFiles2.push_back(line);
}
for(i=0; i<AllFiles2.size();  i++)
n++;
return n;
}


int main() 
{ 
vector  <string> Keywords=words(); 
int c=0;
int  FeatureNumbers=0;
Check(Keywords,ling,c); 
c++;  
Check(Keywords,spam,c);
return 0; 
}
georgioue
Newbie Poster
1 post since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

>>PLEASE HELP ME!!!!!

help you do what? does your program compile ? (hint: no it does not).
what errors does your compiler produce?

if(txt.find(a)!=txt.end()) {  
cout<<
}

Above is incomplete statement.

Ancient Dragon
Retired & Loving It
Team Colleague
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
 

i did try compiling it and it gave me error messages

Nimz
Newbie Poster
8 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

What are some of the errors -- you'll have to post them because I can't see your computer's monitor from my chair.

Ancient Dragon
Retired & Loving It
Team Colleague
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You