This section of code should take all of the words from wordlist.txt, and filter out any duplicates, however it doesn't work. There are no error messages, but when I check del_wordlist.txt, it is the same as wordlist.txt. Does anyone know why this is happening?
CODE
} else if (sW=="delsort")
{
string temp;
int count=0;
cout << "** Commencing Sorted Duplicate Word Deletion **" << endl;
vector<string> wordlist;
delwords.open("del_wordlist.txt");
wordslist.open("wordlist.txt");
while (!wordslist.eof())
{
wordslist >> temp;
wordlist.push_back(temp);
count += 1;
cout << "** Gathering Word List, " << count << " Word(s) Gathered **" << endl;
}
wordslist.close();
cout << "** Testing Word Duplication on all Words **" << endl;
for (int p=0;p<wordlist.size();p++)
{
for (int k=0;k<15;k++)
{
if (wordlist[p]==wordlist[k] && p!=k)
{
cout << "** Duplicate Detection In Word " << p << ", (" << wordlist[p] << ")" << " **" << endl;
wordlist[k]="";
}
}
}
cout << "** Writing Words to del_wordlist.txt **" << endl;
for (int p=0;p<wordlist.size();p++)
{
if (wordlist[p]!="")
{
delwords << wordlist[p] << endl;
}
}
delwords.close();
cout << "** Word Duplication Detection Finished **" << endl;
break;