fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int values[] = { 40, 10, 100, 90, 20, 25, 12, 13, 10, 40 };
  5.  
  6. int compare (const int *a, const int *b)
  7. {
  8. return *a - *b;
  9. }
  10.  
  11. int main ()
  12. {
  13. int n;
  14. for (n=0; n<10; n++)
  15. {
  16. printf("%d ",values[n]);
  17. }
  18. printf("\n");
  19. qsort (values, 10, sizeof(int), compare);
  20. for (n=0; n<10; n++)
  21. {
  22. printf ("%d ",values[n]);
  23. }
  24. printf("\n");
  25. system("pause");
  26. return 0;
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:19: error: invalid conversion from ‘int (*)(const int*, const int*)’ to ‘int (*)(const void*, const void*)’
prog.cpp:19: error:   initializing argument 4 of ‘void qsort(void*, size_t, size_t, int (*)(const void*, const void*))’
prog.cpp:25: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
stdout
Standard output is empty