S
someone
On page 106 of the second edition of "The C Programming Language" by K
& G, two stack operations PUSH n POP are given.
*p++ = val;
val = *--p;
What I know about stacks is that the top of stack (tos) pointer pts to
the topmost element of the stack.
But going by the PUSH operation, the 'va' gets stored in *p first and
then the address of p is incremented by ++ which I think will
OVERWRITE the previous tos. Similarly with pop.
I thought about it and came to the following conclusion:
( either I am missing out on operator PRECENDENCE and its
associativity)
||
( the tos points always to an empty element just above the actual
element on top of the stack)
&&
( I am totally CONFUSSED
)
please clear my doubts. Thanks in advance
& G, two stack operations PUSH n POP are given.
*p++ = val;
val = *--p;
What I know about stacks is that the top of stack (tos) pointer pts to
the topmost element of the stack.
But going by the PUSH operation, the 'va' gets stored in *p first and
then the address of p is incremented by ++ which I think will
OVERWRITE the previous tos. Similarly with pop.
I thought about it and came to the following conclusion:
( either I am missing out on operator PRECENDENCE and its
associativity)
||
( the tos points always to an empty element just above the actual
element on top of the stack)
&&
( I am totally CONFUSSED
please clear my doubts. Thanks in advance