Initialization of arrays and character arrays

In C, array initialization and declaration can be done both at the same time.

Syntax of array initialization:

type_specifier array_name[size1][size2]. . .[sizeN] = { value_list };

For Example:

int a [6] = {1, 2, 3, 4, 5, 6};

Character arrays can be initialized as:

char array_name[size] = “string”

For Example:

char str[13]  = “More Process”;

We always have to leave a character space for the null character.

Leave a Reply