This time I have a vector of names, some of them are duplicates. I am having troubles figuring out how to copy just the duplicates to a second vector and remove the them form the first vecotor. So far I got this:
But this code coppiec all elements from vector friends to vector enemies. How can I fix this ?Code:for ( int i = 0 ; i < friends.size () ; i ++ ) { for ( int j = i - 1 ; j < friends.size () ; j++ ) { if ( friends[i] == friends [j] ) // if duplicate is found { cout << friends[i] << endl; enemies.push_back ( friends [i] ) } } }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.