*str++ in while loop seems have different behaviour with *i++

Viewed 42

*str++ in while loop seems assign first and ++ after.

    int len = 0;
    while (*str++ != 0) {
        len++;
    }

but in most cases, *i++ should ++ first and assign after

int i = 4;
int p = &i;
printf("%d", *p++)  // not 5, *p is after ++

Is that true? I've read the operator precedence sheet in C, it told me that *p++ should ++ first and then *p(right to left)

0 Answers
Related