Created
August 15, 2015 05:14
-
-
Save derekli66/5dc7bb038cb7db717eb7 to your computer and use it in GitHub Desktop.
C function to reverse a string
This file contains hidden or 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 | |
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