There is a vector with the specified size:
const int N=5; vector<int>a(N); I fill the vector with push_back;
for (int i=0;i<N;++i) { a.push_back(i+2); } for (int i:a) { cout<<i<<" "; } Displays N zeros, and the elements themselves: 0 0 0 0 0 2 3 4 5 6 How to get rid of zeros?