>I am having troubles figuring out how to copy just the duplicates to a second
>vector and remove the them form the first vecotor.
Good news! That's a common problem. Better news! It's easily solvable with the standard library:
Code:
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
template <typename T, int N>
char (&array(T(&)[N]))[N];
int main()
{
int a[] = {1,2,3,4,4,2,4,3,1,2,3,5,3,4,5,5,3,4,5};
std::vector<int> v ( a, a + sizeof array ( a ) );
std::vector<int>::iterator end;
std::vector<int> save;
// Original list
copy ( v.begin(), v.end(), std::ostream_iterator<int> ( std::cout, " " ) );
std::cout<<'\n';
sort ( v.begin(), v.end() );
end = unique ( v.begin(), v.end() );
save.assign ( end, v.end() );
v.erase ( end, v.end() );
// Final list
copy ( v.begin(), v.end(), std::ostream_iterator<int> ( std::cout, " " ) );
std::cout<<'\n';
// Saved duplicates
copy ( save.begin(), save.end(), std::ostream_iterator<int> ( std::cout, " " ) );
std::cout<<'\n';
}