I want to dynamic declare the function pointer and sort it
#include <stdio.h>
#include <stdlib.h>
int values[] = { 88, 56, 100, 2, 25 };
int main () {
int n;
printf("Before sorting the list is: \n");
for( n = 0 ; n < 5; n++ ) {
printf("%d ", values[n]);
}
int (^comp)() = ^int(const void *a, const void *b) {
return ( *(int*)a - *(int*)b );
};
qsort(values, 5, sizeof(int), /*ERROR*/comp);
printf("\nAfter sorting the list is: \n");
for( n = 0 ; n < 5; n++ ) {
printf("%d ", values[n]);
}
return(0);
}
But I am getting Error below:
error: passing 'int (^)()' to parameter of incompatible type 'int (* _Nonnull)(const void *, const void *)' qsort(values, 5, sizeof(int), /ERROR/comp);
Note: passing argument to parameter '__compar' here int (* _Nonnull __compar)(const void *, const void *));