Cicode Programming Reference > Using Arrays > Declaring the Variable Array Size

Declaring the Variable Array Size

You need to declare the size of the array (the number of elements the array contains), for example:

STRING			StrArray[5];

This single dimension array contains 5 elements. The compiler multiplies the number of elements in the array by the size of each element (dependent upon the Data Type), and allocates storage for the array in consecutive memory locations.

You cannot declare arrays local to a function. However, they can be declared as Module (that is at the beginning of the Cicode file), or Global. When referring to the array within your function, take to care to remain within the size you set when you declared the array. The example below would cause an error:

STRING   StrArray[5];
StrArray[10] = 100;

The compiler allows storage for 5 strings. By assigning a value to a 10th element, you cause a value to be stored outside the limits of the array, and you could overwrite another value stored in memory.

See Also

Using Arrays

Using Cicode Files