Najlepsza opcja to użycie std::reverse
#include <algorithm>
#include <iostream>
#include <string>
int main()
{
std::string test {"Hello world"};
std::cout << "Oryginalny string: " << test << "\n";
std::reverse(test.begin(), test.end());
std::cout << "Odwrocony string: " << test << "\n";
return 0;
}
Wynik działania programu
Oryginalny string: Hello
Odwrocony string: olleH
Łatwo i prosto bez pisania zbędnych funkcji, które i tak są już bibliotece standardowej.