fork download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int comp1(const void* a, const void* b)
  5. {
  6. return strlen(*(char**)a) - strlen(*(char**)b);
  7. }
  8.  
  9. int main()
  10. {
  11. char* sort_char_array[] = { "about", "this", "and", "url", "that", "the", "i", "hi" };
  12. qsort(sort_char_array, 8, sizeof(char*), comp1); //about and hi i that the this url
  13. for (int i = 0; i < 8; i++)
  14. printf("%s\n",sort_char_array[i]);
  15. }
  16.  
Success #stdin #stdout 0s 5416KB
stdin
Standard input is empty
stdout
i
hi
and
url
the
this
that
about