title: How to elegantly initialize vector<char *> with string literal?
body: <p>The problem comes from an exercise on C++ Primer 5th Edition:</p>
  
  <blockquote>
    <p>Write a program to assign the elements from a list of char* pointers
    to C-style character strings to a vector of strings.</p>
  </blockquote>
  
  <p>----------------Oringinal Question------------</p>
  
  <p>First I try the following somewhat direct way:</p>
  
  <pre><code>vector&lt;char *&gt; vec = {"Hello", "World"};
  vec[0][0] = 'h';
  </code></pre>
  
  <p>But compiling the code I get a warning:</p>
  
  <pre><code>temp.cpp:11:43: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
       vector&lt;char *&gt; vec = {"Hello", "World"};
                                             ^ 
  </code></pre>
  
  <p>And running the ./a.out I get a </p>
  
  <pre><code>Segmentation fault (core dumped)
  </code></pre>
  
  <p>I think it is because I try to write to a const char. So I try another way:</p>
  
  <pre><code>char s1[] = "Hello", s2[] = "World";
  vector&lt;char *&gt; vec = {s1, s2};
  vec[0][0] = 'h';
  </code></pre>
  
  <p>It is OK this time. But it seems a little tedious. Is there any other elegant way to initialize a vector with string literal?</p>