Quick actions

cmd+k|ctrl+k

Navigation

Languages

C, Precedence vs Order of Eval

Snippet info

Language

C

Visibility

public

Author

kurt.westphal

Created

2020-05-21T01:16:28Z

Updated

2020-05-21T10:16:29Z

/*
 * precedence is not the same thing as order of Eval (OoE)
 * see the following tables
 * K&R pg 53
 * Stroustroup pg 
 * precedence of ++ is greater than unary *
 * precenence tells us how opeartors are matched up with operands
 * 
 * *p++ ; what does this mean
 *        *p says take the contents of pointer p
 *        ++ says we're incrementing something (either pointer or value pointed at, but which)
 * how do you evaluate it
 * 
 */
#include <stdio.h>

int main(void) {
    
    int a[10] = { 0,1,2,3,4,5,6,7,8,9};
    int *p = &a[5] ;
    int  i = *p++ ;
    
    printf("%d %d\n", i, *p) ;
    return 0;
}
INFO