Created
April 16, 2014 17:03
-
-
Save crimx/10907677 to your computer and use it in GitHub Desktop.
String Reverse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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