I havent done C++ in a while.
Im trying to get a vector of vectors to print data. I get the following error:
Segmentation fault (core dumped)
I am using an online complier to run the code.
#include <iostream>     // std::cout
#include <algorithm>    // std::for_each
#include <vector>       // std::vector
void myfunctiontwo (int i) {  // function:
  std::cout << ' ' << i;
}
void myfunction (std::vector<int> myvector) {  // function:
  for_each (myvector.begin(), myvector.end(), myfunctiontwo);
}
int main () {
  // create a vector of vectors. 
  std::vector< std::vector<int> > myvector; 
  // add some data
  myvector[0].push_back(10); 
  myvector[1].push_back(20);
  myvector[2].push_back(30);
  std::cout << "myvector contains:";
  for_each (myvector.begin(), myvector.end(), myfunction);
  std::cout << '\n';
  return 0;
}
 
     
    