I have the code, listed below, which I am trying to get to remove any duplicate football team names from a string vector. However, it is only working sometimes, it will remove duplicate names for some of the teams; but then for others there will be multiple occurrences of the same team name in the final array.
For example it would print:
aresnal
wigan
villa
liverpool
villa
Notice there are two 'villa' names, could anyone give me a suggestion? The 'finalLeague' is the array which is storing all of the names, and is the array which needs the duplicates removing out of.
for (int i = 0;i < finalLeague.size();i++)
{
string temp = finalLeague[i];
int h = i + 1;
for (int j = i+1;j < finalLeague.size();j++)
{
if (finalLeague[j] == finalLeague[i])
{
finalLeague.erase(finalLeague.begin()+j);
}
}
}