Is there a way to find how many values an array has? Detecting whether or not I've reached the end of an array would also work.
C++ – How to Find the Length of an Array
arraysc++
arraysc++
Is there a way to find how many values an array has? Detecting whether or not I've reached the end of an array would also work.
Best Answer
If you mean a C-style array, then you can do something like:
This doesn't work on pointers (i.e. it won't work for either of the following):
or:
In C++, if you want this kind of behavior, then you should be using a container class; probably
std::vector
.