I have a struct holding an int.
typedef struct n {
int cars;
struct n *next;
} node;
I make nodes such as node *temp;
This is because I start with a linked list, and then go through it and add them to an array.
Which are then added to an array node **arr;
So I have an array of pointers to pointers. My question is: how can I do a qsort on this? My attempts up to now have resulted in:
qsort(arr, numberCars, sizeof(node), sortCars);
int sortCars(const void *i1, const void *i2){
node *a = (node*)i1, *b = (node*)i2;
return (a->cars - b->cars);
}
I'm having difficulty figuring out what qsort is actually pointing to.