Skip to content

Instantly share code, notes, and snippets.

@pauldwhitman
Last active November 13, 2016 09:58
Show Gist options
  • Save pauldwhitman/3436404 to your computer and use it in GitHub Desktop.
Save pauldwhitman/3436404 to your computer and use it in GitHub Desktop.
Reverses a string using malloc()
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