+ 3
How to get array length in C++
3 Answers
+ 3
You ca. do it like this:
sizeof(arr) / sizeof(*arr);
+ 1
int list[5];
int amount = list.size()
+ 1
simplier, you can use vectors instead of arrays
#include <vector>
vector<int> vec;
vec.push_back(7);
vec.push_back(46);
vec.push_back(16);
cout << vec.size() << endl;
for(int i= 0; i<vec.size(); i++){
cout << vec[i] << " ";
}
3
7 46 16