C++ vector size() function
Example
Find out the size of a vector:
vector<string> cars = {"Volvo", "BMW", "Ford", "Mazda"};
cout << cars.size();
Try it Yourself »
Definition and Usage
The size()
function returns the number of elements in a vector.
Syntax
vector.size();
Parameter Values
None.
Technical Details
Returns: | The number of elements in a vector. |
---|
Related Pages
Read more about vectors in our Vector Tutorial.