pmcgee

Qsort - Clang 5.0.0

Feb 21st, 2021
470
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <iostream>
  3.  
  4. int sort_function( const void* a, const void* b)  {
  5.     return( strcmp((char*)a,(char*)b) );
  6. }
  7.  
  8. const   int    N       = 5;
  9. typedef char   str[4];
  10.         str    list[N] = { "cat", "car", "cab", "cap", "can" };
  11.  
  12. int main()  {
  13.    qsort((void*)list, N, sizeof(str), sort_function);
  14.  
  15.    for (auto x : list)  std::cout << x << "\n";
  16.  
  17.    getchar();
  18.    return 0;
  19. }
RAW Paste Data