Created
April 29, 2015 19:42
-
-
Save bdw/adabd2e2dfbfdd204978 to your computer and use it in GitHub Desktop.
lvalue demonstration
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
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