Is there a max array length limit in C++?

后端 未结 12 1711
深忆病人
深忆病人 2020-11-22 07:21

Is there a max length for an array in C++?

Is it a C++ limit or does it depend on my machine? Is it tweakable? Does it depend on the type the array is made of?

12条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 08:15

    I would agree with the above, that if you're intializing your array with

     int myArray[SIZE] 
    

    then SIZE is limited by the size of an integer. But you can always malloc a chunk of memory and have a pointer to it, as big as you want so long as malloc doesnt return NULL.

提交回复
热议问题