fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. void reverse_cout(std::string str) {
  5. for(std::string::reverse_iterator rit = str.rbegin();
  6. rit != str.rend(); ++rit)
  7. std::cout << *rit;
  8. }
  9.  
  10. int main() {
  11. std::cout << "Enter a sentence/phrase: " << std::endl;
  12. std::string phrase; std::getline(std::cin, phrase);
  13.  
  14. reverse_cout(phrase);
  15. std::cout << std::endl;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3472KB
stdin
program
stdout
Enter a sentence/phrase: 
margorp