How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
Use the std::reverse method from STL:
std::reverse(str.begin(), str.end());
You will have to include the "algorithm" library, #include.
#include