jeudi 26 mars 2015

how to filter through a Text document for banned words stored in an Array

As you can see below i have created an Array for my banned.txt file to go into i will be using another file called text.txt with a sentence in and this is the document that needs to be searched through i would also like the code to show the ammount of times the word appears i think i would be able to do this on my own using a simple for loop with a counter. Any help on how i could filter through my other text file using this array would be greatly appreciated thanks in advance :)



#include <iostream>
#include <fstream>
#include <string>

using namespace std;

string bannedWords[8];





int main()
{
int choice;

int i;
ifstream file("banned.txt");
if (file.is_open())//file is opened
{


for (int i = 0; i < 8; ++i)
{
file >> bannedWords[i];
}

}
else //file could not be opened
{
cout << "The banned words document could not be opened." << endl;
}


cout << "Please Select Which Document you would like to compare" << endl;
cout << "1.Text Document 1" << endl;
cout << "2.Text Document 2" << endl;
cout << "3.Text Document 3" << endl;
cin >> choice;


if (choice == 1)
{
//This is were the search function will be placed



}



system("pause");

}

Aucun commentaire:

Enregistrer un commentaire