title: adding strings to a vector of vector
body: <p>I was trying to add a string to the end of a vector of vector of strings, and somehow encountered memory problem.</p>
  
  <p>my code is something similar to this</p>
  
  <pre><code>vector&lt;vector&lt;string&gt;&gt; slist;
  
  ....
  
  slist.push_back(vector1);
  slist.push_back(vector2);
  
  ...
  
  for(int i=0; i&lt;10; i++){
      int length = slist.size()-1;
      slist[length].push_back("String"); // also tried slist.back().push_back("S");
  }
  </code></pre>
  
  <p>And this some how gives me a memory problem</p>
  
  <pre><code>Invalid read of size 8
  ==2570==    at 0x404D18: std::vector&lt;std::string, std::allocator&lt;std::string&gt;              &gt;::push_back(std::string const&amp;) (stl_vector.h:735)
  ==2570==    by 0x403956: main (asm.cc:400)
  ==2570==  Address 0xfffffffffffffff0 is not stack'd, malloc'd or (recently) free'd
  ==2570==
  ==2570==
  ==2570== Process terminating with default action of signal 11 (SIGSEGV)
  ==2570==  Access not within mapped region at address 0xFFFFFFFFFFFFFFF0
  ==2570==    at 0x404D18: std::vector&lt;std::string, std::allocator&lt;std::string&gt; &gt;::push_back(std::string const&amp;) (stl_vector.h:735)
  ==2570==    by 0x403956: main (asm.cc:400)
  ==2570== 
  </code></pre>
  
  <p>Can anyone tell me why??</p>
  
  <p>PS: sorry about the previous poorly asked question..</p>