Last active
February 11, 2018 19:48
-
-
Save ethagnawl/4eb738fe84d109551f821803e0bb9cb3 to your computer and use it in GitHub Desktop.
demo which shows how to rewind string pointer
This file contains 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
// run with: `gcc main.c -include stdio.h && ./a.out` | |
int main() { | |
char *foo = "foo"; | |
char *bar = foo; | |
char *begin = bar; | |
while (*bar++) {} | |
bar = begin; | |
printf("%s\n", bar); // foo | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment