ABL electronic PIC12 Benutzerhandbuch

Seite von 312
The derived types are also known as structured types. These types are used as ele-
ments in creating more complex user-defined types.
Arrays
Array is the simplest and most commonly used structured type. 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
composed of elements of 
type
.
The 
type
can be scalar type (except 
void
), user-defined type, pointer, enumera-
tion, or another array. Result of the 
constant-expression
within the brackets
determines the number of elements in array. If an expression is given in an array
declarator, it must evaluate to a positive constant integer. The value is the number
of elements in the array.
Each of the elements of an array is numbered from 0 through the number of ele-
ments minus one. If the number 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];
/* an array of 10 integers */
float
vector_two[MAX];
/* an array of 50 floats   */
float
vector_three[MAX - 20];
/* an array of 30 floats   */
MikroElektronika:  Development  tools  -  Books  -  Compilers
65
page
mikroC - C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
DERIVED TYPES