Reputation: 9
I have to q sort an array but for a given range for ex.
Given array
4 5 3 7 2 1
and then i have the range 2 & 5 this means i have to sort from index 2 all the way through 5.
Resultant array
4 5 2 3 7 1
I know we can set one bound like
qsort(array,4,sizeof(int),compa)
this will sort the array till 3rd index but will always start from index 0. I want to start the first bound by a desired value. Any Suggestions??
Upvotes: 0
Views: 597
Reputation: 75062
Just pass address to the middle of the array.
qsort(array + 2, 5 - 2, sizeof(int), compa);
Upvotes: 6