Array length

Arrays and collections / Arrays

#include <iostream>
#include <vector>
using namespace std;

int array[] { 1, 2, 3, 4, 5 };
//since C++20 or size() since C++17
int arLength = ssize(array);
//arLength is 5

vector<int> numbers { 1, 2, 3 };
long vecLength = numbers.size();
//vecLength is 3

cout << "arLength is " << arLength << endl;
cout << "vecLength is " << vecLength;