title: Confusion regarding output of a program related to Null character
body: <p>In the below program arr is a char array whose length is 4. On running it in C compiler I found that the output is tjyh.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      char arr[4];
      arr[0]='t';
      arr[1]='j';
      arr[2]='y';
      arr[3]='h';
      printf(&quot;%s&quot;,arr);
      return 0;
  }
  </code></pre>
  <p>I am confused as where is the Null character. Since a string ends with a '\0' there should be space to accommodate it. How does &quot;%s&quot; know when to stop. Since there is no '\0', there should be garbage values after tjyh or the output should just be tjy since the last character is '\0' which replaced 'h'.</p>
  <p>Edit: Well, I ran this code in <a href="https://www.codechef.com/ide" rel="nofollow noreferrer">Codechef</a> compiler and got the output to be tjyh and no garbage values and if you think that it should also print garbage values then please tell me for how long should it print garbage values as I did not entered '\0', so when would the program stop printing?</p>