Confused about output of following 2 sets of code. Postfix and Prefix notation.
the way I understood book:
Using Xcode 3.3 , gcc 4.2
postfix notation passes on value to i before it increments.
prefix notation increments before it passes value to i.
-----------------------------------------------------------
Postfix notation code
-----------------------------------------------------------
for (i = 0; i < 4; i++)
printf( "first for: i=%d\n", i );
printf( "After first for loop, i=%d.\n\n", i );
------------------------------------------------------------
Postfix notation code output
------------------------------------------------------------
first for: i=0
first for: i=1
first for: i=2
first for: i=3
After first for loop, i=4.
-------------------------------------------------------------
Prefix notation code
-------------------------------------------------------------
for (i = 0; i < 4; ++i)
printf( "first for: i=%d\n", i );
printf( "After first for loop, i=%d.\n\n", i );
-------------------------------------------------------------
Prefix notation code output
-------------------------------------------------------------
first for: i=0
first for: i=1
first for: i=2
first for: i=3
After first for loop, i=4.
Why do both sets of code output the same?
rj