2. Embedded SQL for C : C Variables and Data Types : Variable and Type Declarations : Array Declarations Syntax
 
Share this page                  
Array Declarations Syntax
The syntax of a C array declaration is:
array_name[dimension] {[dimension]}
In the context of a simple variable declaration, the syntax is:
type_specification array_variable_name[dimension] {[dimension]};
In the context of a type declaration, the syntax is:
typedef type_specification array_type_name[dimension] {[dimension]};
Note:   
The preprocessor does not parse the dimension specified in the brackets. Consequently, the preprocessor accepts any dimensions. However, it also accepts illegal dimensions, such as non-numeric expressions, although these later cause C compiler errors. For example, the preprocessor accepts both of the following declarations, even though only the second is legal C:
typedef int SQUARE["bad expression"];
            /* Non-constant expression */
int cube_5[5][5][5];
You can specify any number of dimensions. The preprocessor notes the number of dimensions when the variable or type is declared. When you later reference the variable, it must have the correct number of indices.
You can initialize an array variable, but the preprocessor does not verify that the initial value is an array aggregate.
Variables cannot have grouping parentheses in their references or declarations.
An array of characters is considered to be the pseudo character string type.
Example: Array declarations usage
# define COLS 5
typedef short SQUARE[COLS][COLS];
 SQUARE sq;
static int matrix[3][3] =
                { {11, 12, 13},
                {21, 22, 23},
                {31, 32, 33} };
char buf[50];