fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string str = "";
  7.  
  8. std::cout << "Please enter a string to be reversed: ";
  9. std::getline(std::cin, str);
  10.  
  11. std::cout << "Before: " << str << '\n'
  12. << "After: " << std::string(str.rbegin(), str.rend()) << std::endl;
  13.  
  14. return 0;
  15. }
Success #stdin #stdout 0s 3276KB
stdin
asdf
stdout
Please enter a string to be reversed: Before: asdf
After: fdsa