Skip to content

Instantly share code, notes, and snippets.

@reportbase
Created March 22, 2015 21:13
Show Gist options
  • Save reportbase/b1d1c965dc096487d8d0 to your computer and use it in GitHub Desktop.
Save reportbase/b1d1c965dc096487d8d0 to your computer and use it in GitHub Desktop.
reverse a string
inline void reverse_string(char* A)
{
#define SWAPVAR(A,B) (A^=B, B^=A, A^=B)
char* B = A;
while(B && *B) ++B;
for(--B; A < B; ++A, --B) SWAPVAR(*A, *B);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment