'Array[n] vs Array[10] - Initializing array with variable vs numeric literal

I am having the following issue with my code:

int n = 10;
double tenorData[n]   =   {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

Returns the following error:

error: variable-sized object 'tenorData' may not be initialized

Whereas using double tenorData[10] works.

Anyone know why?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source