title: In C programming, why does square bracket get a higher precedence than prefix operator ++ in the statement: "a[i] = ++i;"?
body: <p>I ran the following code through gcc based C compiler:</p>
  <pre><code>int main() {
      int i = 0;                              // Line 1
      static int a[10];                       // Line 2
      
      a[i] = ++i;                             // Line 3
      
      printf(&quot;%d %d&quot;, a[0], a[1]);            // Line 4
      
      return 0;                               // Line 5
  }
  </code></pre>
  <p>As per the precedence table provided in the textbook &quot;The C Programming Language by Brian Kernighan and Dennis Ritchie&quot; and the website: <a href="https://en.cppreference.com/w/c/language/operator_precedence" rel="nofollow noreferrer">https://en.cppreference.com/w/c/language/operator_precedence</a>,  the precedence of square brackets (array subscript operator) is higher than that of prefix operator ++.</p>
  <p>On running the program, the output i receive is: a[1] = 1.</p>
  <p>I don't understand why the sequence of operations is not as follows:</p>
  <ol>
  <li>a[0]
                            (put i = 0)</li>
  <li>++i                             (increment i by 1)</li>
  <li>a[0] = 1
           
  (assign value of i to a[0])</li>
  </ol>
  <p>and instead works as</p>
  <ol>
  <li>++i
                            (increment i by 1)</li>
  <li>a[1]
                            (put i = 1)</li>
  <li>a[1] = 1
           
  (assign value of i to a[1])</li>
  </ol>
  <p>breaking the precedence rule. Please help me know where I'm going wrong.</p>