Skip to content

Instantly share code, notes, and snippets.

@derekli66
Created August 15, 2015 05:14
Show Gist options
  • Save derekli66/5dc7bb038cb7db717eb7 to your computer and use it in GitHub Desktop.
Save derekli66/5dc7bb038cb7db717eb7 to your computer and use it in GitHub Desktop.
C function to reverse a string
void
reverseStr(char *str)
{
int len = 0;
int init = 0;
while (*(str + len) != '\0') {
len++;
}
len--;
while (init < len) {
char temp = *(str + init);
*(str + init) = *(str + len);
*(str + len) = temp;
init++;
len--;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment