fork download
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4.  
  5. void sort_words(char *words[], int count) {
  6. qsort(words, count, sizeof(*words), (int (*)(const void*, const void*))strcmp);
  7. }
  8.  
  9. #ifndef RunTests
  10. int main()
  11. {
  12. char *words[] = { "cherry", "orange", "apple" };
  13.  
  14. sort_words(words, 3);
  15.  
  16. for (int i = 0; i < 3; i++)
  17. {
  18. printf("%s ", words[i]);
  19. }
  20. }
  21. #endif
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
cherry orange apple