Pastebin launched a little side project called HostCabi.net, check it out ;-)Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Reverse

By: a guest on Oct 14th, 2012  |  syntax: C++  |  size: 0.28 KB  |  hits: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }