title: Char pointer subtraction in C
body: <p>I have read about integer pointer subtraction in C in this thread: <a href="https://stackoverflow.com/questions/3238482/pointer-subtraction-confusion">Pointer subtraction confusion</a>, which was simple enough to grasp and test out.</p>
  
  <p>However, I tried to replicate a similar scenario with a char* but the results that I get did not make much sense.</p>
  
  <p>Here's the scenario that I tried:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main() {
  
      char a_arr[16] = "";
      char *a = a_arr;
      char b_arr[1] = "";
      char *b = b_arr;
  
      printf("\nThe amount by which they differ is: %d\n", a-b);
      // a-b = 1, which makes sense since they are 1 char away
  
      return 0;
  }
  </code></pre>
  
  <p>The next thing that I tried is what I'm having trouble understanding</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main() {
  
      char a_arr[16] = "";
      char *a = a_arr;
      char b_arr[2] = "";
      char *b = b_arr;
  
      printf("\nThe amount by which they differ is: %d\n", a-b);
      // a-b = 16, which doesn't really make sense to me..    
  
      return 0;
  }
  </code></pre>
  
  <p>My guess is that there is some padding stuff going on from the compiler's end which I thought shouldn't be the case since it is a char array and there would be no need for alignment..</p>
  
  <p>I'm not sure why it is 16 bytes.. Any help is much appreciated!</p>
  
  <p>I have used the following online interface to compile and run this piece of code:
  <a href="http://www.tutorialspoint.com/compile_c_online.php" rel="nofollow noreferrer">http://www.tutorialspoint.com/compile_c_online.php</a></p>