[Solved] is it okay to declare an array like this: `int arr[3/0]` in C++? [closed]


Arrays in C (or C++) are blocks of memory. The compiler needs to know how big the array is in order to allocate the needed amount of memory. They are not expandable. To make an array bigger, you have to allocate a new array with more memory, and copy the old array into it.

There are solutions to this though. If you need something that can allocate additional memory as more items are added, then you’ll need to use a class such as the container class “vector”.

For more info, search on “C++ Containers”.

7

solved is it okay to declare an array like this: `int arr[3/0]` in C++? [closed]