// program to sort numbers using qsort library routine
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <search.h>
int sort_function( const void *a, const void *b);
int list[8] = { 12,34,56,2023, 3445,223, 5454,4 };
int main(void)
{
int x;
clrscr();
qsort((void *)list, 8, 2, sort_function);
for (x = 0; x < 8; x++)
printf("%d\n", list[x]);
// return 0;
getch();
}
int sort_function(const void *a, const void *b)
{
int x,y;
// return( strcmp((int *)a,(int *)b) );
if(b<a)
return (-1);
else
return (1);
}
OUTPUT IS COMING OUT TO BE
223
34
12
4
56
5454
2023
3445
// The problem is definitely with the sort function. I tried to return a and b instead of 1 and -1 but with no change . please help me out