How are variables on the stack accessed?
Suppose we have these local variables: int a = 0; int b = 1; int c = 2; int d = 3; As far as I know, these will be allocated on the system stack, like this: | | | 3 | d | 2 | c | 1 | b |_0_| a Does this mean that in order to get the value of a, the values of d, c and b must first be popped out of the stack? If so, where do these values go? Does this mean that accessing more recently declared variables will be faster? Or am I missing something (which I suspect is the case), and the whole thing works in some other way?
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.