A question of Precedence: Two functions from a C stack.

B

benmarco7

benmarco, April 23, '08

Preface: s is a struct pointer, items[ ] is a member array, and top is
a member int.


void push(Stack *s, int i) { s -> items[s -> top++] = i; }

ORDER Operator
1st left most -> comment: Postfix ++ is lower
than =
2nd [ ] but this one
executes before =
3rd 2nd -> because it's
inside [ ].
4th Postfix ++
5th =

int pop(Stack *s) { return s -> items[--s -> top]; }

ORDER Operator
1st left most -> comment: All the operators
in pop( )
2nd [ ] are Level 1.
Prefix -- executes
3rd Prefix -- before the 2nd -
. Does this
4th 2nd -> mean that s
itself gets decrimented?

If so, would that cause s to no longer point at the struct
instance?

benmarco, < think like a compiler > atleast try.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top