This is my attempt using pointers, The way you told me worked, i just want to get it to work this way. I think the prob is with my compar function, it compiles but I get output
miceli
ZY$�
monroe
�EE<fu�E�E}wʋU�
�
here is my compar function
Code:
int comp(const void *a, const void *b) {
char *pa, *pb;
pa = (char *) a;
pb = (char *) b;
return strcmp(pa, pb);
}
here is my function that calls qsort
Code:
void showasa(void) {
char *index[20];
short x;
for(x=0;x<12;x++) {
*(index+x) = seats[x].name.last;
}
qsort(index, sizeof(index) / sizeof(index[0]), sizeof(index[0]), comp);
for(x=0;x<12;x++) {
printf("%s\n",index[x]);
}
putchar('\n');
}
I really appreciate your help so far.