How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
Use std::reverse()
reverse(begin(str), end(str));
And that's it.