title: Don't understand why while(*ptr++) enter while loop for 0 value (string terminator)
body: <p>I have a problem with the following apperently trivial sample code:
  (on visual studio 2015)</p>
  
  <p>Please ignore the part with pointing to a literal constant, possible warnings or erros on the newwer compiler, that is not what I don't understand.</p>
  
  <p>My problem is why it prints '0' and how the while loop works, tried using both debugger and printf. My understanding of the problem is this:</p>
  
  <ol>
  <li><p>moves ptr to point at 'e'</p></li>
  <li><p>checks content of ptr which is 'e' it is not 0 so it enters while loop</p></li>
  <li>back to condition line, moves ptr to 'l'</li>
  <li>checks *ptr, it is not 0, enters...
  blah blah for the letters l, o</li>
  </ol>
  
  <p>Then it increases ptr after 'o' and gets '\0', at which point by my logic it should NOT enter the loop, but i does, and no longer enters after one more step when it is pointing over the terminator at junk?!?</p>
  
  <p>I looked over 2 other topics, <a href="https://stackoverflow.com/questions/5209602/pointer-arithmetic-ptr-or-ptr">this topic about operator precedence</a> and <a href="https://stackoverflow.com/questions/12201815/what-difference-between-whilepp-while-p-and-whilep">this one about the while(*ptr) case going over the terminator</a>, but I don't understand from the second WHY it enters the loop and thy it increases the pointer value afterwards? for what i understand the order is first increase pointer, then get the value with *</p>
  
  <pre><code>#include &lt;cstdio&gt;
  #include&lt;stdlib.h&gt;
  
  int main(void) {
      char* str = "hello";
      char* ptr = str;
      char least = 127;
      while (*ptr++) {
          printf("%c-", *ptr);
          least = ((*ptr) &lt; (least)) ? (*ptr) : (least);
      }
      printf("%d\n", least);
  }
  </code></pre>