I am very new to vectors and would like know how assignment works in case of a vector of vectors [2-D Vector].
I want to input a list of elements(from stdin) to the first row of the vector of vectors. How should I go about it?
I tried to assign it as-
I realize that this is naive and is throwing a seg fault. I know how .push_back works in case of 1-D vectors but am not sure what to do here. Please help.
std::vector<std::vector<int>> v;
v.push_back( std::vector<int>() );
constint N = 10;
v[0].reserve( N );
for ( int i = 0; i < N; i++ )
{
std::cout << "Enter a number: ";
int x;
std::cin >> x;
v[0].push_back( x );
}