English
Language : 

CC78K0S Datasheet, PDF (68/520 Pages) NEC – C Compiler Ver.1.30 or Later Language
CHAPTER 3 DECLARATION OF TYPES AND STORAGE CLASSES
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 character string literal so
that the length indicates a “char array” type object.
char *p="abc";
(4) Initialization of aggregate or union type objects
• Aggregate type
An aggregate type object is initialized with 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 which has a static storage
duration.
With an array of unknown size, the number of 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 of initializer for the first member of the union that is enclosed in braces.
In the following example, the array “x” of 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
};
In the following example, the elements in the first row of “z” are initialized to the specified values and the rest of
the elements are initialized to 0.
68
User’s Manual U14872EJ1V0UM