![]() The advantage of this method is that it is easier to understand. In the above example, there is a total of three rows so there are three sets of inner braces. Each set of inner braces represents one row. This type of initialization makes use of nested braces. We can initialize a 2D array in C by using an initializer list as shown in the example below.įirst Method: int x = Initialization of 2D array using Initializer List The various ways in which a 2D array can be initialized are as follows:ġ. Initialization of Two-Dimensional Arrays in C We can also create an array dynamically in C by using methods mentioned here. Note: In this type of declaration, the array is allocated memory in the stack and the size of the array should be known at the compile time i.e.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |