Skip to content

Instantly share code, notes, and snippets.

@kevinlynx
Created April 5, 2014 15:32
Show Gist options
  • Save kevinlynx/9993459 to your computer and use it in GitHub Desktop.
Save kevinlynx/9993459 to your computer and use it in GitHub Desktop.
int length(char *str) {
int s = 0;
for (; *str; ++str) ++s;
return s;
}
char *reverse(char *str) {
int size = length(str);
for (int i = 0; i < size / 2; ++i) {
str[i] ^= str[size - i - 1];
str[size - i - 1] ^= str[i];
str[i] ^= str[size - i - 1];
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment