title: Difference between string and char[] types in C++
body: <p>I know a little C and now I'm taking a look at C++.
  I'm used to char arrays for dealing with C strings, but while I look at C++ code I see there are examples using both string type and char arrays:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main () {
    string mystr;
    cout &lt;&lt; "What's your name? ";
    getline (cin, mystr);
    cout &lt;&lt; "Hello " &lt;&lt; mystr &lt;&lt; ".\n";
    cout &lt;&lt; "What is your favorite team? ";
    getline (cin, mystr);
    cout &lt;&lt; "I like " &lt;&lt; mystr &lt;&lt; " too!\n";
    return 0;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main () {
    char name[256], title[256];
  
    cout &lt;&lt; "Enter your name: ";
    cin.getline (name,256);
  
    cout &lt;&lt; "Enter your favourite movie: ";
    cin.getline (title,256);
  
    cout &lt;&lt; name &lt;&lt; "'s favourite movie is " &lt;&lt; title;
  
    return 0;
  }
  </code></pre>
  
  <p>(both examples from <a href="http://www.cplusplus.com" rel="noreferrer">http://www.cplusplus.com</a>)</p>
  
  <p>I suppose this is a widely asked and answered (obvious?) question, but it would be nice if someone could tell me what's exactly the difference between that two ways for dealing with strings in C++ (performance, API integration, the way each one is better, ...).</p>
  
  <p>Thank you.</p>