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:
std::vector<std::vector<int> > v(12);
void fun_1(std::vector<int> a )
{
for (int i = 0; i < 5; ++i)
{
a.push_back(i);
}
}
int main()
{
for (int i = 0; i < 12; ++i)
{
fun_1(v[i]);
}
cout<<v[0].at(2);
}
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.