title: vector<char> to string segmentation fault
body: <p>trying to initialize a string from a vector. I am supposed to get "hey" as the output. but I got "segmentation fault". what did I do wrong?</p>
  
  <pre><code>//write a program that initializes a string from a vector&lt;char&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  using namespace std;
  int main ()
  {
      vector&lt;char&gt; cvec;
      cvec[0]='h';
      cvec[1]='e';
      cvec[2]='y';
      string s(cvec.begin(),cvec.end());
      cout&lt;&lt;s&lt;&lt;endl;
      return 0;
  }
  </code></pre>