<p>What is the difference between</p>

<pre><code>char str1[32] = "\0";
</code></pre>

<p>and </p>

<pre><code>char str2[32] = "";
</code></pre>

[{'answer_id': 49620, 'author': 'Kyle Cronin', 'author_id': 658, 'author_profile': 'https://Stackoverflow.com/users/658', 'pm_score': 6, 'selected': True, 'text': '<p>Since you already declared the sizes, the two declarations are exactly equal. However, if you do not specify the sizes, you can see that the first declaration makes a larger string:</p>\n\n<pre><code>char a[] = "a\\0";\nchar b[] = "a";\n\nprintf("%i %i\\n", sizeof(a), sizeof(b));\n</code></pre>\n\n<p>prints</p>\n\n<pre><code>3 2\n</code></pre>\n\n<p>This is because a ends with two nulls (the explicit one and the implicit one) while b ends only with the implicit one.</p>\n'}, {'answer_id': 49622, 'author': 'Nathan Fellman', 'author_id': 1084, 'author_profile': 'https://Stackoverflow.com/users/1084', 'pm_score': 0, 'selected': False, 'text': "<p>Unless I'm mistaken, the first will initialize 2 chars to 0 (the '\\0' and the terminator that's always there, and leave the rest untouched, and the last will initialize only 1 char (the terminator).</p>\n"}, {'answer_id': 49805, 'author': 'Larry Gritz', 'author_id': 3832, 'author_profile': 'https://Stackoverflow.com/users/3832', 'pm_score': 2, 'selected': False, 'text': '<p>As others have pointed out, "" implies one terminating \'\\0\' character, so "\\0" actually initializes the array with two null characters.</p>\n\n<p>Some other answerers have implied that this is "the same", but that isn\'t quite right.  There may be no practical difference -- as long the only way the array is used is to reference it as a C string beginning with the first character.  But note that they do indeed result in two different memory initalizations, in particular they differ in whether Str[1] is definitely zero, or is uninitialized (and could be anything, depending on compiler, OS, and other random factors).  There are some uses of the array (perhaps not useful, but still) that would have different behaviors.</p>\n'}, {'answer_id': 59445, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': False, 'text': '<p>Well, assuming the two cases are as follows (to avoid compiler errors):</p>\n\n<pre><code>char str1[32] = "\\0";\nchar str2[32] = "";\n</code></pre>\n\n<p>As people have stated, str1 is initialized with two null characters:</p>\n\n<pre><code>char str1[32] = {\'\\0\',\'\\0\'};\nchar str2[32] = {\'\\0\'};\n</code></pre>\n\n<p>However, according to both the C and C++ standard, if part of an array is initialized, then remaining elements of the array are default initialized.  For a character array, the remaining characters are all zero initialized (i.e. null characters), so the arrays are <em>really</em> initialized as:</p>\n\n<pre><code>char str1[32] = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\n                 \'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\n                 \'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\n                 \'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'};\nchar str2[32] = {\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\n                 \'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\n                 \'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\n                 \'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\',\'\\0\'};\n</code></pre>\n\n<p>So, in the end, there really is no difference between the two.</p>\n'}]
['https://Stackoverflow.com/questions/49596', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/123/']