i have this struct:
typedef struct arvDado Arv;
struct arvDado{
char c;
int qtd;
Arv* dir;
Arv* esq;
};
and i am making a array of pointer of this struct :
Arv** vetArv = (Arv**)malloc(sizeof(Arv*)*qtd);
i want to make a qsort but i think that my comper function is not working...
comper function:
int comparaCelula(const void *x, const void *y){
Arv *a=(Arv*)x, *b=(Arv*)y;
printf(" %d x %d",a->qtd,b->qtd);
if(a->qtd == b->qtd) return 0;
if(a->qtd < b->qtd) return -1;
if(a->qtd > b->qtd) return 1;
}
for any case with you want to see my implementation of qsort is this:
array of point of Arv = Arv** vetCell / size of vet = qtd / size of struct Arv / comper function
qsort(vetCel, qtd, sizeof(Arv*), comparaCelula);
Arv*. I don't see you initializing your array anywhere.