Last active
November 13, 2016 09:58
-
-
Save pauldwhitman/3436404 to your computer and use it in GitHub Desktop.
Reverses a string using malloc()
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
char* newString = malloc(sizeof(char)*length+1); | |
for (i=length-1, j=0; i>=0; i--, j++) { | |
newString[j] = input[i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment