All pastes #80398 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-07-06 11:25 UTC
rendered paste body
#include<stdio.h>
#include<stdlib.h>
int comparefn(const void *a, const void *b)     //Always void *
{
        int result = *(int *)a - *(int *)b;     //Casting impt
        return result;                          //return int always
}
int main()
{
        int arr[] = {5,4,3,2,1},i;
        qsort(arr,5,sizeof(int),comparefn);     //params dep on arr type .. 5 is the no of elems
        for(i = 0;i<5;i++)
                printf("%d\n",arr[i]);
        return 0;
}