SHARE
TWEET

Reverse

a guest Oct 14th, 2012 37 Never
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. const string str = "Hello world";
  8. string revStr = "";
  9. for (unsigned int i = 0; i <= str.length(); i++)
  10.   revStr += str[str.length()-i];
  11.  
  12.  cout << "the reversed string is :  " << revStr << endl;
  13.  
  14. }
RAW Paste Data
Top