| jimmiej (4) | |
|
#include <iostream> #include <fstream> #include <cstring> #include <string> using namespace std; const int max_cpl = 250; //max characters per line in file const int max_wpl = 20; //max words per line const char* const words = " "; int i = 0; //number for word int w = 0; //number of stopwords int main() { // create a reading object ifstream fin; ifstream stopwords; fin.open("reut2-000.sgm"); // open a file stopwords.open("stopwords.txt"); if (!fin.good()) return 1; // exit if file not found if(!stopwords.good()) return 1; // read each line of the file while (!fin.eof()) { // read an entire line char buf[max_cpl]; char startword[max_cpl]; fin.getline(buf, max_cpl); stopwords.getline(startword,max_cpl); const char* word[max_wpl] = {0}; const char* stopw[max_wpl]={0}; stopw[0]=strtok(startword,words); word[0] = strtok(buf, words); if (word[0] != " ") { for (i = 1; i < max_wpl; i++) { word[i] = strtok(0, words); if (!word[i]) break; } } if (word[0] == 0) continue; if (stopw[0] != " ") { for (w = 1; i < max_wpl; w++) { stopw[w]=strtok(0,words); if (!stopw[w]) break; } } if (word[0] == 0) continue; for(int k =0; k < i; k++) { for (int s = 0; s < w; s++) // i = #of words {//HELP ME HERE IT WORK COMPARE if(stopw[s] != word[k]) { cout << "Word[" << k << "] = " << word[k] << endl; cout << endl; } } } } return 0; }
| |
|
Last edited on
|
|