I cannot, for the life of me, get this qsort() to work. I have tried for several hours to get it to work. I think it has to do with the fact that I am qsort'ing a 2d array whereas the library is designed to qsort a 1d array.
Here is a copy of some of the code I am using. If you need more info, just let me know. Please help ASAP! Thank you!
Code:
(structure definition in header file)
typedef struct darray{
char (*primarray) [1024];
int capacity;
int size;
} darray;
(in c file)
void da_sort(darray *da){ /* The qsort function */
qsort(da->primarray, 1024, sizeof(char), compare_chars);
}
int compare_chars(const void* a, const void* b) { /* the compare function to go with qsort*/
char* arg1 = (char*) a;
char* arg2 = (char*) b;
if( *arg1 < *arg2 ) return -1;
else if( *arg1 == *arg2 ) return 0;
else return 1;
}

