How do I find the length of an array?

前端 未结 27 2936
轮回少年
轮回少年 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:26

    For C++/CX (when writing e.g. UWP apps using C++ in Visual Studio) we can find the number of values in an array by simply using the size() function.

    Source Code:

    string myArray[] = { "Example1", "Example2", "Example3", "Example4" };
    int size_of_array=size(myArray);
    

    If you cout the size_of_array the output will be:

    >>> 4
    

提交回复
热议问题