Suppose I have this piece of code:
#include <iostream>
int array[];
int main()
{
int length;
std::cin >> length;
for (int i = 0; i < length; i++)
{
std::cin >> array[i];
}
}
This does not work since I did not declare the size of the array at the start of the program. However, I am not able to declare the size of the array since the length of the array depends on user input and I only get this input after I declare the array. (I require this array to be a global variable so I cannot declare it after declaring the length variable)