C++ arrays | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C++ arrays

In C++ is there a way to get the arrays length like in JS when you use .length. Thank you for your help.

2nd Jun 2018, 8:26 AM
Bradley
5 Answers
+ 6
Arrays don't really know their own sizes. Use std::vector, or std::array. https://www.sololearn.com/learn/261/?ref=app http://en.cppreference.com/w/cpp/container/array
2nd Jun 2018, 9:09 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
...For what you're doing, you can really just do... cin >> arr2[0];
2nd Jun 2018, 12:23 PM
Hatsy Rei
Hatsy Rei - avatar
0
Well, is there a way to make arrays dynamic like, could I cin a int into a array?
2nd Jun 2018, 9:23 AM
Bradley
2nd Jun 2018, 10:36 AM
Bradley
0
So vecters are like the arrays in JS
2nd Jun 2018, 7:59 PM
Bradley