How do I find the length of an array?

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

    Doing sizeof( myArray ) will get you the total number of bytes allocated for that array. You can then find out the number of elements in the array by dividing by the size of one element in the array: sizeof( myArray[0] )

提交回复
热议问题