Amount of objects in an Array?

Is there a way to get the amount of objects in an array? I'm trying to make a login, and it's Array based...
Depends on the situation.
I suggest you using std::vector instead of arrays
I'm still learning C++... I don't know what std::vector is... Sorry. Which lesson is it under?
You can use vector like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <vector>
#include <iostream>

int main()
{
   std::vector<int> vec(3);

   vec[0] = 5;
   vec[1] = 9;
   vec[2] = 2;

   for(size_t i = 0; i < vec.size(); ++i)
   {
      std::cout << vec[i] << '\n';
   }
}


To get the number of objects in the vector use vec.size().
Topic archived. No new replies allowed.