title: C++: C-style String Acting Like An Array Of Chars?
body: <p>Hello to anyone reading this. I am new to C++. I have some conceptual questions about C-strings.
  I learned that <strong>C-string acts like an array</strong> from another stack discussion, but I am confused by the following:</p>
  <p>I know that in C++, <strong>for arrays</strong>:</p>
  <pre><code>int int_arr[] = {1, 2, 3, 4, 5}; 
  cout &lt;&lt; int_arr &lt;&lt; endl;        // Address of first element of the array, prints an address
  cout &lt;&lt; *int_arr &lt;&lt; endl;       // Content of first element of the array, prints 1
  // int_arr acts like &amp;(int_arr[0]) in assignment, comparison, etc.
  </code></pre>
  <p>I expected the same behavior for <strong>C-strings</strong>, but:</p>
  <pre><code>char c_str[] = &quot;Hello&quot;;
  cout &lt;&lt; c_str &lt;&lt; endl;          // Prints &quot;Hello&quot;
  cout &lt;&lt; *c_str &lt;&lt; endl;         // Prints &quot;H&quot;
  </code></pre>
  <p><strong>This contradicts the behavior of the array.</strong><br />
  The following setup has the same behavior as a C-string:</p>
  <pre><code>char *c_string = &quot;Hello&quot;;
  cout &lt;&lt; c_string &lt;&lt; endl;      // Prints &quot;Hello&quot;
  cout &lt;&lt; *c_string &lt;&lt; endl;     // Prints &quot;H&quot;
  </code></pre>
  <p>There are two questions here:</p>
  <ul>
  <li>Is it correct that C-string <strong>does not act like an array</strong>, and I am supposed to remember C-string with its own behavior? If it is an array, <strong>why does it act differently</strong> in the above example of arrays, not returning the address but the whole string?</li>
  <li>Is the third code section simply <strong>another way of setting up a C-string</strong>? It only works when it is a <code>char*</code>. (<strong>Resolved</strong>)</li>
  </ul>