Skip to content

Instantly share code, notes, and snippets.

@bdw
Created April 29, 2015 19:42
Show Gist options
  • Save bdw/adabd2e2dfbfdd204978 to your computer and use it in GitHub Desktop.
Save bdw/adabd2e2dfbfdd204978 to your computer and use it in GitHub Desktop.
lvalue demonstration
int * foo(void) {
int a = 4;
return &a;
}
int main() {
int a[5];
a[1] = 3; /* we assign something to the location a[1] */
printf("%d\n", a[0]); /* and now we read from the (uninitialized) location a[0] */
*(foo()) = 5; /* and now we assign to the pointer returned by foo */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment