Multi-Dimensional Arrays in C Programming Language
Let’s understand the concept of multi-dimensional arrays in C programming language.
Although arrays with more than two dimensions are not commonly used, C does allow any number of dimensions to be declared. This is done by listing maximum size of all dimensions of the array. For example, the declaration:
declares a three-dimensional array. The first element in the array is designated as
a and the last element as
Thus, generally speaking, multidimensional arrays in C programming language are defined in much the same manner as one-dimensional arrays, except that a separate pair of square brackets are required for each subscript. Hence, a two-dimensional array requires two pairs of square brackets
, a three-dimensional array will requie three pairs of square brackets
, and so on.
In general terms, a multidimensional array definition in C programming language can be written as:
storage-class data-type array[expression 1][expression 2]...[expression n];
storage-class refers to the storage class of the array,
data-type is its data type,
array is the name of the multidimensional array, and
expression 1, expression 2, ..., expression n are positive valued integer expressions that indicate the number of array elements associated with each subscript.
Remember that the
storage-class is optional. The default values are automatic for arrays that are defined inside of a function, and external for arrays defined outside of a function.
very useful thanx
Thanks for explaining character arrays and string arrays very well here