Array size set by variable
Hi,
I am having issues compiling a program with cc on a fairly old unix system, I understand that I need to follow C standards strictly but I can find no way around this.
Code:
array(int n)
{
int i;
int array[n];
for(i=0;i<=n-1;i++)
{
array[i]=i+1;
}
exit(0);
}
It is a simple function to setup an array to size n which is collected and passed in from the main function. The compiler is freaking at the array declaration, saying that I have declared an array of 0 and that the expression is not constant, as it compiles line by line and this is the last function I am happy with the rest of my code.
Does anyone have any ideas how I can get around this?
Thanks