Modify length of a vector in c ++

0

I want to modify the length of a vector and at the same time delete the remaining elements if the new length is smaller than the original length of the vector. I do not know if there will be reserved words of the language to do this. It is with this type of vector: std::vector nombre[];

    
asked by Walk Rock 18.06.2018 в 01:05
source

1 answer

1

Look at this is an example of how to do it, I hope it works for you

vector<int> blabla;
for(int i = 1; i <= 10; i++)
    blabla.push_back(i);

blabla.resize(blabla.size()-1);

for(int i = 0; i < blabla.size(); i++)
    std::cout << blabla[i] << std::endl;
    
answered by 18.06.2018 / 15:24
source