Hi everyone. I'm currently designing a dynamic array which will hold strings of length 0 to 1024. I have finished all of the methods except for the method that sorts the dynamic array in order from lowest to highest (ASCII value).

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!

(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;

Last edited by shabbir; 10Mar2007 at 11:02.. Reason: Code formating.