+ 3
How to find length of array in c++ ?
4 Answers
+ 11
https://stackoverflow.com/questions/4108313/how-do-i-find-the-length-of-an-array
else, why not use dynamic arrays i.e. <vector>
+ 8
An array length counting code
https://code.sololearn.com/cIdHe7Dqo9kX/?ref=app
+ 7
Interger version
https://code.sololearn.com/c7PPjRmo24ve/?ref=app
+ 3
#include <iostream>
#include <array>
using namespace std;
int main () {
array<int,5> myArr;
cout << "size: " << myArr.size() << endl;
int arr[5];
cout << "sizeof: " << sizeof(arr)/sizeof(*arr) << endl;
}
Personally, except for simple cases, I use the first form of array.