#include <algorithm>
#include <iostream>
#include <string>
int main()
{
std::string foo("foo");
std::string copy(foo);
std::cout << foo << '
' << copy << '
';
std::reverse(copy.begin(), copy.end());
std::cout << foo << '
' << copy << '
';
}
string reverse(string str)
{
string output;
for(int i=str.length()-1; i<str.length(); i--)
{
output += str[i];
}
return output;
}
string name1 = "Sam" ;
string name2 = name1 ; /// Have to store the ORIGINAL in ANOTHER variable ...then Reverse that
reverse(name2.begin(),name2.end()) ;
cout << name2 ; // maS