+ 3

How to get array length in C++

24th May 2019, 7:31 PM
Anuradha Nayanajith
Anuradha Nayanajith - avatar
3 ответов
+ 3
You ca. do it like this: sizeof(arr) / sizeof(*arr);
24th May 2019, 7:40 PM
Airree
Airree - avatar
+ 1
int list[5]; int amount = list.size()
24th May 2019, 8:19 PM
Cat Sauce
Cat Sauce - avatar
+ 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
24th May 2019, 8:29 PM
Choe
Choe - avatar