fork(4) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <cstring>
  4.  
  5. int main()
  6. {
  7. char const* strings[] = {
  8. "hello",
  9. "world",
  10. "computers",
  11. "are",
  12. "awesome"
  13. };
  14.  
  15. struct {
  16. bool operator()(char const* a, char const* b) const {
  17. return (a && b)? 0 > strcmp(a,b) : a < b;
  18. }
  19. } cmp;
  20.  
  21. std::sort(std::begin(strings), std::end(strings), cmp);
  22.  
  23. for (auto& s : strings)
  24. std::cout << s << "\n";
  25. }
  26.  
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
are
awesome
computers
hello
world