title: How to iterate over std::vector<char> and find null-terminated c-strings
body: <p>I have three questions based on the following code fragments<br>
  I have a list of strings. It just happens to be a vector but could potentially be any source    </p>
  
  <pre><code>vector&lt;string&gt; v1_names = boost::assign::list_of("Antigua and Barbuda")( "Brasil")( "Papua New Guinea")( "Togo");
  </code></pre>
  
  <p>The following is to store lengths of each name<br></p>
  
  <pre><code>vector&lt;int&gt; name_len;
  </code></pre>
  
  <p>the following is where I want to store the strings<br>  </p>
  
  <pre><code>std::vector&lt;char&gt; v2_names;
  </code></pre>
  
  <p>estimate memory required to copy names from v1_names<br></p>
  
  <pre><code>v2_names.reserve( v1_names.size()*20 + 4 );
  </code></pre>
  
  <p><strong>Question:</strong> is this the best way to estimate storage? I fix the max len at 20 that is ok, then add space for null treminator<br>
  Now copy the names<br></p>
  
  <pre><code>for( std::vector&lt;std::string&gt;::size_type i = 0; i &lt; v1_names.size(); ++i)
  {
      std::string val( v1_names[i] );
      name_len.push_back(val.length());
      for(std::string::iterator it = val.begin(); it != val.end(); ++it)
      {
          v2_names.push_back( *it );
      }
      v2_names.push_back('\0');
  }
  </code></pre>
  
  <p><strong>Question:</strong> is this the most efficient way to copy the elements from v1_name to v2_names?<br> 
  <strong>Main Question:</strong> How do I iterate over v2_names and print the country names contained in v2_names</p>