How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
With C++ lambda:
auto reverse = [](std::string& s) -> std::string { size_t start = 0, end = s.length() -1; char temp; while (start < end) { temp = s[start]; s[start++] = s[end]; s[end--] = temp; } return s; };