Skip to content

Instantly share code, notes, and snippets.

@ethagnawl
Last active February 11, 2018 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethagnawl/4eb738fe84d109551f821803e0bb9cb3 to your computer and use it in GitHub Desktop.
Save ethagnawl/4eb738fe84d109551f821803e0bb9cb3 to your computer and use it in GitHub Desktop.
demo which shows how to rewind string pointer
// 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