How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string?
But I think the XOR swap algorithm is the best...
char str[]= {"I am doing reverse string"}; char* pStr = str; for(int i = 0; i != ((int)strlen(str)-1)/2; i++) { char b = *(pStr+i); *(pStr+i) = *(pStr+strlen(str)-1-i); *(pStr+strlen(str)-1-i) = b; }