title: Explanation behind arithmetic pointer post increment output in C
body: <pre><code>void x(){
  
       int x[] = {9, 8, 7, 6, 5, 4, 3, 2, 1}; 
       int *p = x + 1;
  
           while (*p++ &gt;5)
           printf ("%d ", *p); 
           printf ("\n");
  
  }
  </code></pre>
  
  <p>Output: {7, 6, 5}</p>
  
  <p>I wanted to double check my rationale behind what the proper output for this is, given the precedence and associativity in C. </p>
  
  <p>When the function is called, it executes top down, taking no arguments. </p>
  
  <p>First we have an array x of 9 elements. </p>
  
  <p>Second we have a pointer p, which points to element x[1]; </p>
  
  <p>Third, we jump into the while loop, which is true for everytime *p++ > 5. 
  What is evaluated first here is post incrementing the address of p++, so for the first element x[1], we have a value of 8 which is greater than 5, so p is incremented (p++ = x[2] = 7) x[2] = 7 becomes the new *p value (since it points to x[2] now) and 7 is printed. </p>
  
  <p>Next we have 7 which is greater than 5, p is incremented (p++ = x[3] = 6) so 6 is printed and then we have 6 which is still greater than 5, p is incremented (p++ = x[4] = 5) so 5 is printed, we have so far {7, 6, 5} printed. </p>
  
  <p>Then we evaluate the position of x[4] which is 5, which is not greater than 5, so we jump out of the while loop and ends up with the output. {7, 6, 5}. </p>
  
  <p>Is my reasoning for this question correct? </p>