Get length of an Array using a pointer

后端 未结 6 1832
广开言路
广开言路 2021-01-03 05:25

Is there a way to get the length of an Array when I only know a pointer pointing to the Array?

See the following example

int testInt[3];
testInt[0] =         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 06:13

    You cannot and you should not attempt deduce array length using pointer arithmetic

    if in C++ use vector class

提交回复
热议问题