title: No out of bounds error
body: <p>I have this code in C which takes in bunch of <code>char</code>s</p>
  
  <pre><code>#include&lt;stdio.h&gt; 
  # define NEWLINE '\n'
  int main()
  {
  
  char c;
  char str[6];
  int i = 0;
  while( ((c = getchar()) != NEWLINE))
  {
          str[i] = c;
          ++i;
          printf("%d\n", i);
  }
  
  return 0;
  }
  </code></pre>
  
  <p>Input is: testtesttest</p>
  
  <p>Output:
  1
  2
  3
  4
  5
  6
  7
  8
  117
  118
  119
  120</p>
  
  <p>My questions are: </p>
  
  <ol>
  <li><p>Why don't I get an out of bounds (segmentation fault) exception although I clearly exceed the capacity of the array? </p></li>
  <li><p>Why do the numbers in the output suddenly jump to very big numbers? </p></li>
  </ol>
  
  <p>I tried this in C++ and got the same behavior. Could anyone please explain what is the reason for this?</p>