fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. void rev_str ()
  6. {
  7. char str[81];
  8. cout << "Please enter a string: ";
  9. cin.getline(str, 81);
  10. int len = cin.gcount();
  11.  
  12. for (int i = 0; i < len--; i++) {
  13. // http://e...content-available-to-author-only...e.com/w/cpp/algorithm/swap
  14. swap(str[i], str[len]);
  15. }
  16.  
  17. cout << str << endl;
  18. }
  19.  
  20. int main() {
  21.  
  22. rev_str();
  23. return 0;
  24. }
Success #stdin #stdout 0s 3300KB
stdin
Dark Souls
stdout
Please enter a string: sluoS kraD