qsort in c code example
Example 1: qsort in c
#include
int cmpfunc (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
int main () {
//n is number of elements in arr(size f that arr)
qsort(arr, n, sizeof(int), cmpfunc);
}
Example 2: definition qsort c program
void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))