Expression evaluation order
<p>I recently got confused by the following c++ snippet:</p>

<pre><code>#include &lt;cstdio&gt;

int lol(int *k){
  *k +=5;
   return *k;
}

int main(int argc, const char *argv[]){
  int k = 0;
  int w = k + lol(&amp;k);
  printf("%d\n", w);
  return 0;
}
</code></pre>

<p>Take a look at line:</p>

<pre><code>int w = k + lol(&amp;k);
</code></pre>

<p>Until now I thought that this expression would be evaluated from left to right: take current value of k (which before calll to lol function is 0) and then add it to the result of lol function. But compiler proves me I'm wrong, the value of w is 10. Even if I switch places to make it </p>

<pre><code>int w = lol(&amp;k) + k;
</code></pre>

<p>the result would be still 10. What am I doing wrong?</p>

<p>Tomek</p>
