fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. char values[] = "mmfa";
  6.  
  7. int cmpfunc(const void * a, const void * b) {
  8. return(*(char *)a - *(char *)b);
  9. }
  10.  
  11. int main() {
  12. int n;
  13. qsort(values, strlen(values), sizeof(char), cmpfunc);
  14. printf("\nAfter sorting the list is: \n");
  15. for(n = 0; n < 5; n++)
  16. printf("%c ", values[n]);
  17. return 0;
  18. }
Success #stdin #stdout 0s 2052KB
stdin
Standard input is empty
stdout
After sorting the list is: 
a f m m