I have a declaration of a 2d vector:

vector<vector<int> > data;

I want to add several times in an server-client problem an array of 25 elements. I donnot know how many times i must add that array(which changes its values). How can i add that element to the vector without declarating the initial size of the vector??

double inputs[23] ={.....};

Any idea about this???Thanks in advanced!

You would need to push_back() each element after creating a new vector with push_back():

while (!done)
{
    // Somehow populate inputs with an unknown number of elements (23 or less)

    int n = /* Number of actual elements in inputs */

    data.push_back(vector<int>()); // Append a new vector

    // Populate the newly appended vector with the contents of inputs
    for (int i = 0; i < n; ++i)
    {
        data.back().push_back(inputs[i]);
    }
}
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.