I have to do a function which, taken as parameters a pointer (int *vect) and the dimension (dim) of the array allocated, returns a new array which contains all the elements of the old array not repeated and all the first occurrence of repeated elements, this is the code where i put the elements not repeated of the first array, but i don't know how to proceed to put the first occurrence of repeated elements (e.g. INPUT : vect={1;2;3;3;4;5;5} OUTPUT : {1;2;3;4;5})
int* deleteDup(int *vect,int dim){
int* vect2,int dim2;
vect2=malloc(sizeof(int)*dim2);
int i,j,temp;
int count=0;
for(i=0;i<dim-1;i++){
temp=vect[i];
for(j=i+1;j<dim;j++){
if(temp==vect[j]){
count++;
}
}
if(count==0){
dim2++;
vect2=realloc(vect2,dim2*sizeof(int));
vect2[dim2]=temp;
}
*dim_nodup=dim2;
return vect2;
}