11123 - Counting Trapizoid
Moderator: Board moderators
the qsort() function from <stdlib.h> is C, not C++
the C++ way is using sort() from <algorithm>
To use any of them, you just need a custom comparison function.
For C:
See the documentation for more info.
the C++ way is using sort() from <algorithm>
To use any of them, you just need a custom comparison function.
For C:
Code: Select all
// warning, not tested
int cmp(const void *aa, const void *bb) {
struct myStruct *a = (struct myStruct *)aa;
struct myStruct *b = (struct myStruct *)bb;
// use aa->member, bb->member
// return -1, 0 or 1
}