Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <iostream>
- int sort_function( const void* a, const void* b) {
- return( strcmp((char*)a,(char*)b) );
- }
- const int N = 5;
- typedef char str[4];
- str list[N] = { "cat", "car", "cab", "cap", "can" };
- int main() {
- qsort((void*)list, N, sizeof(str), sort_function);
- for (auto x : list) std::cout << x << "\n";
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement