Template:cpp/container/vector/example size
From cppreference.com
The following code uses size
to display the number of elements in a std::vector<int>:
Run this code
#include <cassert> #include <vector> int main() { std::vector<int> nums; assert(nums.size() == 0); nums = {1, 2, 3, 4}; assert(nums.size() == 4); }