F
flipflop
I need to create a global array whose dimensions depend on the
contents of another global array populated at its initialisation. For
example:
int array1[3]={3,2,1};
int array2[array1[0]]; //should be equiv. to: int array2[3];
GCC gives these errors:
variable-size type declared outside of any function
variable-sized object may not be initialized
warning: excess elements in array initializer
warning: (near initialization for `array2')
Both arrays need to be global and created before main() starts. Any
ideas?
contents of another global array populated at its initialisation. For
example:
int array1[3]={3,2,1};
int array2[array1[0]]; //should be equiv. to: int array2[3];
GCC gives these errors:
variable-size type declared outside of any function
variable-sized object may not be initialized
warning: excess elements in array initializer
warning: (near initialization for `array2')
Both arrays need to be global and created before main() starts. Any
ideas?