Datasheet

DERIVED TYPES
The derived types are also known as structured types. They are used as elements
in creating more complex user-defined types.
The derived types include:
- arrays
- pointers
- structures
- unions
ARRAYS
Array is the simplest and most commonly used structured type. A variable of array
type is actually an array of objects of the same type. These objects represent ele-
ments of an array and are identified by their position in array. An array consists of a
contiguous region of storage exactly large enough to hold all of its elements.
Array Declaration
Array declaration is similar to variable declaration, with the brackets added after
identifer:
type array_name[constant-expression]
This declares an array named as array_name and composed of elements of type.
The type can be any scalar type (except void), user-defined type, pointer, enumer-
ation, or another array. Result of constant-expression within the brackets deter-
mines a number of elements in array. If an expression is given in an array declara-
tor, it must evaluate to a positive constant integer. The value is a number of ele-
ments in an array.
Each of the elements of an array is indexed from 0 to the number of elements minus
one. If a number of elements is n, elements of array can be approached as variables
array_name[0] .. array_name[n-1] of type.
Here are a few examples of array declaration:
#define MAX = 50
int vector_one[10]; /* declares an array of 10 integers */
float vector_two[MAX]; /* declares an array of 50 floats */
float vector_three[MAX - 20]; /* declares an array of 30 floats */
155
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5