How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
Read Kernighan and Ritchie
#include void reverse(char s[]) { int length = strlen(s) ; int c, i, j; for (i = 0, j = length - 1; i < j; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } }