Arrays and Strings:
An array is a sequential collection of variables, all of the same size and type, called "array elements". A string is an array of characters. For example, in the string “ABC,” each letter is an element. You can access the elements in an array or string relative to the first element.
Declaring and Referencing Arrays:
Array elements occupy contiguous memory locations. The program references each element relative to the start of the array. An array is declared by giving it a name, a type, and a series of initializing values or placeholders (?).
The following example shows how to declare an array of bytes (b_array) and an array of words (w_array):
Initializer lists of array declarations can span multiple lines. The first initializer must appear on the same line as the data type, all entries must be initialized, and, if the array is to continue to the new line, the line must end with a comma.
The following example shows legal multiple-line array declaration:
An array may span more than one logical line, such as the array var1 in the example below, although a separate type declaration is needed in each logical line:
The DUP Operator:
The DUP operator is very often used in the declaration of arrays This operator works with any of the data allocation directives.In the syntax:
count DUP (initialvalue [[, initialvalue]]...)
the count value sets the number of times to repeat all values within the parentheses. The initial value can be an integer, character constant, or another DUP operator, and must always appear within parentheses.
For example, the statement allocates the integer value 1 five times for a total of 5 bytes.:
The following examples show various ways for allocating data elements with the DUP operator: