English
Language : 

CC78K4 Datasheet, PDF (63/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 3 DECLARATION OF TYPES AND STORAGE CLASSES
The next example is the same as the above example of array initialization.
Char s[ ] = {‘a’, ‘b’, ‘c’, ‘\0’},
t[ ] = { ‘a’, ‘b’, ‘c’};
The next example defines p as “pointer to char” type and the member is initialized by a character string literal so
that the length indicates 4 “char array” type objects.
char *p = “abc” ;
(4) Initialization of aggregate or union type objects
• Aggregate type
An aggregate type object is initialized by a list of initializers described in ascending order of subscripts or
members. The initializer list to be specified must be enclosed in braces.
If the number of initializers in the list is less than the number of aggregate members, the members not
covered by the initializers will be implicitly initialized just the same as an object that has static storage
duration.
With an array of an unknown size, the number of its elements is governed by the number of initializers and the
array will no longer become an incomplete type.
• Union type
A union type object is initialized by an initializer for the first member of the union that is enclosed in braces.
In the following example, the array “x” with an unknown size will change to a one-dimensional array that has
three elements as a result of its initialization.
int x[ ] = {1, 3, 5} ;
The next example shows a complete definition which has initializers enclosed in braces. “{1, 3, 5}” initializes
“y [0] [0]”, “y [0] [1]”, and “y [0] [2]” in the 1st line of the array object “y[0]”. Likewise, in the second line, the
elements of the array objects “y [1]” and “y [2]” are initialized. The initial value of “y[3]” is 0 since it is not
specified.
char y [4] [3] = {
{1, 3, 5},
{2, 4, 6},
{3, 5, 7},
};
The next example produces the same result as the above example.
char z[4][3] = {
1, 3, 5, 2, 4, 6, 3, 5, 7
};
User’s Manual U15556EJ1V0UM
63