I made a program to delete duplicates in an array but the program\'s if condition always remain true. I understood what the problem was,changed arr[i] to arr[count] and allocate
You never initialized arr. Currently it's just a pointer, it has no actual bound on it, so you could be overwriting something else.
Also, you're never incrementing scanf("%d",&arr[i]); I think you want that to read scanf("%d",&arr[counter]);
To remove duplicates from array create a method, that:
To use quicksort in c, you need comparator function like:
int comp(const void *x, const void *y) {
return (*(int*)x - *(int*)y);
}
And then you can call it with:
qsort(array, 10, sizeof(int), comp);
To count unique items in sorted array, iterate over the array, and do something like:
if(sortedarray[i]!=sortedarray[i+1]) count++;