Hi, I just want to make sure of something. Say we have the following declarations:
Code:
int list[6] = {10, 20, 30, 40, 50, 60};
int *p = list;
Given this information, we were given an exercise to do in class about pointer arithmetic.
I understand that *++p = 20, by first incrementing p and dereferencing, and the following code of *p++ = 20 also because p is pointing to the second element of the array, dereferences, and then increments p to the next element. The code after that, however, is *(p++) which evaluates to 30, which I'm a little confused about. Shouldn't it be 40? Since the code previous to that incremented p already to point to list[2], and it's incrementing p first to point to list[3] then dereferencing? Only way I could see it being 30 is if *(p++) is the same as *p++, but it seems like that defies the rule of precedence.