C/C++ Arena

Step 1 of 6

std::vector basics

std::vector<T> is a growable array that manages its own memory. It's everything you built by hand with realloc, done right.

#include <vector>

std::vector<int> v = {3, 1, 4};
v.push_back(1);           // append: {3, 1, 4, 1}
v.size();                 // 4
v[0];                     // 3
v.back();                 // 1
v.pop_back();             // remove last

Your turn: fill in the blanks.

Next: Loop over a vector