I want to use qsort() to sort array a with respect to b. Can you give me the function?
a={0,1,2,3,4}
b={3,4,5,1,2}
answer must be {3,4,0,1,2}
Please give me the code of function.
like :
int compare (const void *a,const void *b)
{
return(*(char *)a-*(char *)b);
}
This isn’t possible the way you currently have it because qsort() takes in one array and compares elements of the array against each other. You would need to create a single array of a struct containing both values, like so: