mardi 3 mars 2015

find a word in string using text file


I am trying to find if the string has english word in it. i have tons of string to compare with dictionary text file. I want to score each array string if that string has english words in it.



string STRING;
ifstream infile;
string str[2][50];

string str[0][0] = "ADAEIJVAIHELLOKAJAKJ";
string str[0][1] = "EIBJVDJAPPLEKNUUDIEH";
...

for (int j = 0; j < 2; j++)
{
for (int i = 0; i < array_size; i++)
{
int score = 0;
while (!infile.eof())
{
getline(infile, STRING);
if (str.find(word))
score++;
}
cout << str[j][i] << " has" << score << " words in it" << endl;
}
}


But i think i am not getting right dictionary words, i think did wrong with getline(infile, STRING). Also i am not sure if str.find(word) will work... any help? thanks in advance




Aucun commentaire:

Enregistrer un commentaire