Skip to content

Instantly share code, notes, and snippets.

@crimx
Created April 16, 2014 17:03
Show Gist options
  • Save crimx/10907677 to your computer and use it in GitHub Desktop.
Save crimx/10907677 to your computer and use it in GitHub Desktop.
String Reverse
void swap(char *a, char *b) {
*a = *a^*b;
*b = *a^*b;
*a = *a^*b;
}
void reverse(char *a) {
if(!a) return;
int i, n = -1;
while(a[++n]);
for(i=0; i<n/2; i++) {
swap(a+i, a+n-1-i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment