Datasheet

Array Initialization
An array can be initialized in declaration by assigning it a comma-delimited
sequence of values within braces. When initializing an array in declaration, you can
omit the number of elements – it will be automatically determined according to the
number of elements assigned. For example:
/* Declare an array which holds number of days in each month: */
int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
/* This declaration is identical to the previous one */
int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
If you specify both the length and starting values, the number of starting values must
not exceed the specified length. The opposite is possible, in this case the trailing
“excess” elements will be assigned to some encountered runtime values from mem-
ory.
In case of array of
char, you can use a shorter string literal notation. For example:
/* The two declarations are identical: */
const char msg1[] = {'T', 'e', 's', 't', '\0'};
const char msg2[] = "Test";
For more information on string literals, refer to String Constants.
Arrays in Expressions
When the name of an array comes up in expression evaluation (except with opera-
tors & and sizeof ), it is implicitly converted to the pointer pointing to array’s first
element. See Arrays and Pointers for more information.
Multi-dimensional Arrays
An array is one-dimensional if it is of scalar type. One-dimensional arrays are some-
times referred to as vectors.
Multidimensional arrays are constructed by declaring arrays of array type. These
arrays are stored in memory in such way that the right most subscript changes
fastest, i.e. arrays are stored “in rows”. Here is a sample of 2-dimensional array:
float m[50][20]; /* 2-dimensional array of size 50x20 */
156
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5