R
redefined.horizons
I would like to have an array declaration where the size of the array
is dependent on a variable. Something like this:
/* Store the desired size of the array in a variable named
"array_size". */
unsigned short int array_size = 25;
/*Declare an array named "numbers" using the variable initialized
above. */
unsigned short int numbers[array_size];
I think that this syntax will work. However, my real problem is this. I
need to include this array in a struct definition that will be in a
header file. Am I allowed to have the "array_size" variable
initialization statement in my header file, and if not, how do I
indicate that the size of the array in my struct is based on a
variable, and not a literal number?
Thanks for the help.
Scott Huey
is dependent on a variable. Something like this:
/* Store the desired size of the array in a variable named
"array_size". */
unsigned short int array_size = 25;
/*Declare an array named "numbers" using the variable initialized
above. */
unsigned short int numbers[array_size];
I think that this syntax will work. However, my real problem is this. I
need to include this array in a struct definition that will be in a
header file. Am I allowed to have the "array_size" variable
initialization statement in my header file, and if not, how do I
indicate that the size of the array in my struct is based on a
variable, and not a literal number?
Thanks for the help.
Scott Huey