title: pointer arithmetic: *p++ and (*p)++ and more
body: <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int k=0;
      int* p=&amp;k;
      printf("%d %d\n", p, k);
      *p++;
      printf("%d %d\n", p, k);
      (*p)++;
      printf("%d %d\n", p, k);
  }
  </code></pre>
  
  <p>The code above prints this in Dev C++:</p>
  
  <p>6422184 0</p>
  
  <p>6422188 0</p>
  
  <p>6412189 0 // p is increased 1 -> ???</p>
  
  <p>The code above prints this in ideone.com:</p>
  
  <p>368737692 0</p>
  
  <p>368737696 0</p>
  
  <p>368737696 0</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int k=0;
      int* p=&amp;k;
      int* t=p; // the only difference
      printf("%d %d\n", p, k);
      *p++;
      printf("%d %d\n", p, k);
      (*p)++;
      printf("%d %d\n", p, k);
  }
  </code></pre>
  
  <p>The code above prints this in Dev C++:</p>
  
  <p>6422180 0</p>
  
  <p>6422184 0</p>
  
  <p>6412184 0</p>
  
  <p>I think (*p)++ increases the value of the variable p is pointing. So I believe the first code should print this in Dev C++:</p>
  
  <p>6422184 0</p>
  
  <p>6422188 0</p>
  
  <p>6412188 0</p>
  
  <p>Does the existence of int* t affect the way (*p)++ works? Or is this just a kind of undefined behavior? I am weak about pointer, please help!</p>