I have push_back(ed) Lines in 6 "places"/for 6 elements lika below in a 2D vector.

So each element of the 6 consist of different many "MainLines".
So when I am trying to get these out in the OutPut, I know I will use any kind of ::iterator and knowing begin() and end() of each element but I am not sure how to get that line correct. I have started this line out below for example 2DVector[1].

std::vector<std::vector<string> > 2DVector(5, std::vector<string>());
2DVector[i].push_back(MainLine.c_str());

ofstream OutPut("C:\\File1");

for( std::vector<string>::iterator it = 2DVector[1].begin(); it !=2DVector[1].end(); it++)
{
    OutPut << 2DVector[1][*it];
}

Use the same logic that you would use if you were outputting a 2D array. Nest two loops, and have two separate indices (in this case, iterators), which keep track of your position in the vector. Something like this:

std::vector< std::vector<int> > my_vector;

// ...

std::vector< std::vector<int> >::iterator iter_x;
std::vector<int>::iterator iter_y;

for (iter_x = my_vector.begin(); iter_x != my_vector.end(); iter_x++)
{
  for (iter_y = iter_x->begin(); iter_y != iter_x->end(); iter_y++)
  {
    // do whatever you want here
    // *iter_y points to the actual data -- in this case, the integer
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.