Created
December 13, 2016 22:16
-
-
Save cbergau/40715a730d62757ce0d6d22417811906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.h> | |
int cmpfunc(const void * a, const void * b) { | |
return ( *(int*)a - *(int*)b ); | |
} | |
int cstring_cmp(const void * a, const void * b) { | |
const char **ia = (const char **)a; | |
const char **ib = (const char **)b; | |
return strcmp(*ia, *ib); | |
} | |
int main() { | |
int values[] = { 22, 23, 454, 1, 2, 3}; | |
qsort(values, 6, sizeof(int), cmpfunc); | |
char *strings[] = { "Zorro", "Alex", "Celine", "Bill", "Forest", "Dexter" }; | |
qsort(strings, sizeof(strings) / sizeof(char *), sizeof(char *), cstring_cmp); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment