title: Size of string vs size of char array in c++
body: <p>I have to write a piece of code and deploy it in a system with limited memory space and was thinking about char arrays vs string . I wrote the following piece of code to get a better idea.</p>
  <pre><code>    string str=&quot;abcde&quot;;
      char carray[6]={'a','b','c','d','e','\0'};
      cout &lt;&lt;&quot;size of char array:&quot;&lt;&lt; sizeof(carray) &lt;&lt; endl ;
      cout &lt;&lt;&quot;size of string:&quot;&lt;&lt; sizeof(str) &lt;&lt; endl ;
  </code></pre>
  <p>The output I get is</p>
  <pre><code>size of char array:6
  size of string:28
  </code></pre>
  <p>So, I have 2 questions</p>
  <ol>
  <li>Can I conclude that using the string will be a foolish idea given that it is taking much more space, given that memory space is tight and the max chars in my array wont be greater than 10?</li>
  <li>Why the hell is size of string  showing as 28? on what basis?</li>
  </ol>