432 Appendix A C Language Summary
defines macros and declares functions for working with complex and imaginary num-
bers. For example, a double_Complexvariable c1can be declared and initialized to the
value 5 + 10.5iwith a statement such as:
double _Complex c1 = 5 + 10.5 * I;
Library routines such as crealand cimagcan then be used to extract the real and imag-
inary part of c1,respectively.
An implementation is not required to support types _Complexand _Imaginary,or
can optionally support one but not the other.
The header file <stdbool.h>can be included in a program to make working with
Boolean variables easier. In that file, the macros bool,true,and falseare defined,
enabling you to write statements such as:
bool endOfData = false;
4.3 Derived Data Types
A derived data type is one that is built up from one or more of the basic data types.
Derived data types are arrays, structures, unions, and pointers. A function that returns a
value of a specified type is also considered a derived data type. Each of these, with the
exception of functions, is summarized in the following sections. Functions are separately
covered in Section 7.0.
4.3.1 Arrays
Single-Dimensional Arrays
Arrays can be defined to contain any basic data type or any derived data type. Arrays of
functions are not permitted (although arrays of function pointers are).
The declaration of an array has the following basic format:
type name[n] = { initExpression, initExpression,... };
The expression ndetermines the number of elements in the array nameand can be
omitted provided a list of initial values is specified. In such a case, the size of the array is
determined based on the number of initial values listed or on the largest index element
referenced if designated initializersare used.
Each initial value must be a constant expression if a global array is defined.There can
be fewer values in the initialization list than there are elements in the array, but there
cannot be more. If fewer values are specified, only that many elements of the array are
initialized.The remaining elements are set to 0.
A special case of array initialization occurs in the event of character arrays, which can
be initialized by a constant character string. For example,
char today[] = "Monday";
declares todayas an array of characters.This array is initialized to the characters 'M',
'o','n','d','a','y',and '\0',respectively.
20 0672326663 AppA 6/10/04 2:01 PM Page 432