how to store vector in a vector c++ : <p>I want to store some int vectors into a vector, so firstly I initialize a vector type vector, then iterate for begin to end, and store int numbers into each subvectoer from 0 to 4 like below code: </p>

<pre><code>std::vector&lt;std::vector&lt;int&gt;  &gt; v(12);

void fun_1(std::vector&lt;int&gt; a )
{
    for (int i = 0; i &lt; 5; ++i)
    {
        a.push_back(i);
    }
}
int main()
{

    for (int i = 0; i &lt; 12; ++i)
    {
        fun_1(v[i]);
    }

    cout&lt;&lt;v[0].at(2);
}
</code></pre>

<p>So after I done that, there is always a segmentation fault which I think is because subvector is still empty, they are not assigned, so I am wondering how can I modify this to reach my goal? Thank for any idea.</p>
