I have defined an array of structs
typedef struct sorting {
int number
} SRT;
SRT *mystr = NULL;
which I later dynamically allocated.
and I want to sort it by the number int;
What kind of function do I have to write in order for qsort to do it? I have written :
qsort(mystr,array_index,sizeof(mystr),magic);
int magic(const void *a, const void *b) {
int one=((const struct mystr*)a)->number;
int two(( const struct myst*)b)->number;
return ( one-two);
}
but it didn't work. How can I do it? it throwed errors about not naming a type.
one - two.