> There is a question here.
There certainly is
> How to use sandard qsort() function?
Like so
Code:
#include <stdio.h>
#include <stdlib.h>
struct item {
int ref_num,minutes,cost_per_min;
float total_weight;
};
// you need 3 more of these
int compare_field1 ( const void *a, const void *b ) {
const struct item *pa = a;
const struct item *pb = b;
if ( pa->ref_num < pb->ref_num ) return -1;
if ( pa->ref_num > pb->ref_num ) return +1;
return 0;
}
int main ( ) {
struct item items[10];
qsort( items, 10, sizeof(struct item), compare_field1 );
return 0;
}
> void recorder( struct item item_array[], int num_items, int sort_field);
All this needs is 4 if statements (testing sort_field) to decide which sort function to call.