I have this comparator function for my qsort in C, but I seem to be getting a segmentation fault no matter what I try...
int textCompare ( const void * a, const void * b ){
const char **x =(const char**)a;
const char **y =(const char**)b;
return strcmp(*x, *y);
}
Here is my qsort call: where message** mList = malloc(INITIAL_CAPACITY * sizeof(message)); and count is an integer keeping track of the last element. message is just a typedef struct that contains an int and a pointer to a char. I'm 67% sure that I am calling qsort correctly, can anyone point me in the right direction?
qsort (*mList, count, sizeof(message), textCompare);
[EDIT] The reason I declare message*** instead of message* is because I'm trying to initialize an "array" of pointers to structures; unless I'm going about this the wrong way?
*mList = malloc(INITIAL_CAPACITY * sizeof(message));.