fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void SortString(char *strings[], int size)
  5. {
  6. char *temp;
  7. for(int i = 0; i < size - 1; i++) {
  8. for(int j = i + 1; j < size; j++) {
  9. if (strcmp(strings[i], strings[j]) > 0) {
  10. temp = strings[i];
  11. strings[i] = strings[j];
  12. strings[j] = temp;
  13. }
  14. }
  15. }
  16. }
  17. int main()
  18. {
  19. char *names[] = {"D", "C", "B", "A"};
  20.  
  21. SortString(names, 4);
  22.  
  23. for (int i=0; i < 4; ++i) {
  24. printf("%s\n", names[i]);
  25. }
  26. }
  27.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
A
B
C
D