How do I find the length of an array?

前端 未结 27 2887
轮回少年
轮回少年 2020-11-21 23:10

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.

27条回答
  •  孤独总比滥情好
    2020-11-21 23:35

    Simply you can use this snippet:

    #include 
    #include 
    #include 
    
    using namespace std;
    
    int main()
    {
    
      array values;
      cout << "No. elements in valuea array: " << values.size() << " elements." << endl;
      cout << "sizeof(myints): " << sizeof(values) << endl;
    
    }
    

    and here is the reference : http://www.cplusplus.com/reference/array/array/size/

提交回复
热议问题