title: Difference between post and pre decrement a char pointer value in c function putchar
body: <p>I have the following code in C (I'm using tdm-gcc 4.9.1 and Netbeans 8.0.2):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  char * pr(char * str);
  
  int main(void)
  {
      char * x;
  
      x = pr("Ho Ho Ho!");
  
      return 0;
  }
  
  //*************************************
  
  char * pr(char * str)
  {
      char * pc;
  
      pc = str;
  
      while (* pc)
      {
          putchar(* pc++);
          printf(" %d %d\n", pc, str);
      }
  
      printf("\n");
      printf(" %d %d\n", pc, str);  
      printf("\n");
  
      do 
      {
          putchar(* pc--); // alternate case: * --pc
          printf(" %d %d\n", pc, str);
      } while (pc - str);
  
      return (pc);
  }
  </code></pre>
  
  <p>In the do-while loop, when the argument inside the putchar function is</p>
  
  <pre><code>* pc--
  </code></pre>
  
  <p>I have the following result printed 
  (1st column prints the string "Ho Ho Ho!", one character at a time, 
   2nd column prints the address of pointer-to-char pc, whereas the
   3rd column prints the address of pointer to char str:</p>
  
  <pre><code>H 4206629 4206628
  o 4206630 4206628
    4206631 4206628
  H 4206632 4206628
  o 4206633 4206628
    4206634 4206628
  H 4206635 4206628
  o 4206636 4206628
  ! 4206637 4206628
  
   4206637 4206628
  
   4206636 4206628
  ! 4206635 4206628
  o 4206634 4206628
  H 4206633 4206628
    4206632 4206628
  o 4206631 4206628
  H 4206630 4206628
    4206629 4206628
  o 4206628 4206628
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Ho Ho Ho!!oH oH o
  </code></pre>
  
  <p>When the argument inside the putchar function is</p>
  
  <pre><code>* --pc
  </code></pre>
  
  <p>The corresponding result is </p>
  
  <pre><code>H 4206629 4206628
  o 4206630 4206628
    4206631 4206628
  H 4206632 4206628
  o 4206633 4206628
    4206634 4206628
  H 4206635 4206628
  o 4206636 4206628
  ! 4206637 4206628
  
   4206637 4206628
  
  ! 4206636 4206628
  o 4206635 4206628
  H 4206634 4206628
    4206633 4206628
  o 4206632 4206628
  H 4206631 4206628
    4206630 4206628
  o 4206629 4206628
  H 4206628 4206628
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Ho Ho Ho!!oH oH oH
  </code></pre>
  
  <p>My question is as follows: What's the difference between the postfix and the prefix decrement operator regarding the output of the putchar function inside the do-while loop?</p>
  
  <p>Any feedback would be greatly appreciated.</p>