Created
August 16, 2012 20:57
-
-
Save leroux/112ba0a0134852bb7f20 to your computer and use it in GitHub Desktop.
Kiyoura's Reverse String Challenge Solution
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
#include <stdio.h> | |
int main (void) { | |
char str[] = "password"; | |
int i = 0; | |
/* for pointer arithmetic */ | |
char *ptr = str; | |
while (*ptr && (*ptr += (i++))) | |
ptr++; | |
printf("%s\n", str); | |
i = 0; | |
ptr = str; // repoint to beginning of string | |
while(*ptr && (*ptr -= (i++))) | |
ptr++; | |
printf("%s\n", str); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment