0

Here is a part of code I am writing.I am getting a segfault in the CmpFunc function.

The segfault occurs when I compare *a and *b i.e in the "if(*a>*b)" line. I am new to function pointers. So, I might be making a mistake somewhere which I don't realize.I would be very much grateful if anyone points out the mistake.

```
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include "functions.h"
void stooge_sort(void* A[], int left, int right){
printf("\n DEBUG\n");
int CmpFunc(const void* _a, const void* _b);
int k=CmpFunc(A[left], A[right]);
if(k==1){
void* temp = A[right];
A[right] = A[left];
A[left] = temp;
}
if(right-left>1){
int t = (right-left + 1)/3;
stooge_sort(A,left,right-t);
stooge_sort(A,left+t,right);
stooge_sort(A,left,right-t);
}
}
int CmpFunc(const void* _a, const void* _b)
{
const float* a = (const float*) _a;
const float* b = (const float*) _b;
printf("\n DEBUG\n");
if(*a > *b) return 1;
else
if(*a == *b) return 0;
else return -1;
}
```