There is a question here.
Write a function which, given an array of structures specified by:
struct item
{
int ref_num,minutes,cost_per_min;
float total_weight;
};
recorders the array(in place) using the qsort() function in stdlib.h so that the array elements have the 'sort_field'(th) field arrange in ascending order after the sort(sort_field has valid values 1 to 4). The 'num_items' parameter indicates the number of array elements to be sorted. The prototype is:
void recorder( struct item item_array[], int num_items, int sort_field);
How to use sandard qsort() function?
I think insertion sort could be easied to be used it for this quesiton?
Pls tell me how to use qsort to do it?
Thanks a lot.



LinkBack URL
About LinkBacks


