+ 3

How to find length of array in c++ ?

4th Nov 2017, 1:44 AM
Harsh Tirkey
Harsh Tirkey - avatar
4 Respuestas
4th Nov 2017, 1:58 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 8
4th Nov 2017, 2:26 AM
Manual
Manual - avatar
4th Nov 2017, 2:28 AM
Manual
Manual - avatar
+ 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.
4th Nov 2017, 2:24 AM
John Wells
John Wells - avatar