fork(3) download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. void reverse( char *s )
  5. {
  6. if ( !s )
  7. return;
  8.  
  9. char *e = s + strlen( s ) - 1;
  10. while ( s < e )
  11. {
  12. *e ^= *s;
  13. *s ^= *e;
  14. *e-- ^= *s++;
  15. }
  16. }
  17. int main() {
  18. // your code goes here
  19. char* s1 = "123";
  20. char* s2 = "";
  21.  
  22. std::cout << s1 << " - " << std::endl;
  23. reverse(s1);
  24. std::cout << s1 << std::endl;
  25.  
  26. std::cout << s2 << " - " << std::endl;
  27. reverse(s2);
  28. std::cout << s2 << std::endl;
  29. return 0;
  30. }
Runtime error #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
123 -