It would be not an efficient solution to the problem, but, using the algorithm library, you might actually
reverse the string:
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string s = "foobar";
string r{s};
reverse(r.begin(), r.end());
cout << "s='" << s << "', r='" << r << "'\n";
}