title: Character array initialization and trailing null
body: <p>When I declare a char array of size 2 and assign data to it when is there a trailing '\0' (null character)?</p>
  
  <p>I know that:</p>
  
  <pre><code>char data[2] = {'a', 'b'}; // array holds 'a', 'b'
  </code></pre>
  
  <p>I also know that</p>
  
  <pre><code>char data[] = "ab"; // array holds 'a', 'b', '\0'
  </code></pre>
  
  <p>However, I'm wondering what this does?</p>
  
  <pre><code>char data[2] = "ab"; // Is there a trailing '\0'?
  </code></pre>
  
  <p>I always thought that this was an error however looking at <a href="https://en.cppreference.com/w/c/language/array_initialization" rel="noreferrer">cppreference</a>
  it says: </p>
  
  <blockquote>
    <p>If the size of the array is known, it <strong>may</strong> be one less than the size of the string literal, in which case the terminating null character is ignored:</p>
  </blockquote>
  
  <pre><code>char str[3] = "abc"; // str has type char[3] and holds 'a', 'b', 'c'
  </code></pre>
  
  <p>So what does "may" mean? Is it implementation dependent?</p>