How to remove identical elements from array of integers

array is allocated dynamically., after that i want to re-size the array...
copying all the value of the array to the temporary array except the value which you want to delete and then copying all the values to the origanal array .
Removing identical Elements
it will probably work only for 1D array.
1. identify the element that needs to be deleted
2. copy all the remaining elements one step to the left
3. when the all the identical elements are overwritten make a new array of smaller size(depending how many elements were overwritten) and copy the old array to new array. again the index upto which the elements need to be copied depends upon how many elements were deleted.
You could use std::vector, rather than an array and std::sort() and std::unique(). Or you could just use a std::set from the outset.

std::vector
http://cplusplus.com/vector

std::sort()
http://cplusplus.com/set

std::unique()
http://cplusplus.com/reference/algorithm/unique/

std::set
http://cplusplus.com/set
Topic archived. No new replies allowed.