1// string::rbegin/rend
2#include <iostream>
3#include <string>
4
5int main ()
6{
7 std::string str ("now step live...");
8 for (std::string::reverse_iterator rit=str.rbegin(); rit!=str.rend(); ++rit)
9 std::cout << *rit;
10 return 0;
11}
1#include <iostream>
2using namespace std;
3
4int main() {
5
6 string greeting = "Hello";
7 int len = greeting.length();
8 int n=len-1;
9 for(int i=0;i<(len/2);i++){
10 //Using the swap method to switch values at each index
11 swap(greeting[i],greeting[n]);
12 n = n-1;
13
14 }
15 cout<<greeting<<endl;
16}