How to sew a top with ruffles
How to insert a signature in an electronic document

HOW do the array

How to make an array

An array is an ordered structure containing data of a certain type. There are one-dimensional (linear) arrays and multi-dimensional data sets.

Usually one-dimensional array may include only elements of the same type.

Typically, access to the array can be obtained by its name, which is an address in the memory array.

an array can contain, as standard data types, as well as by structure, classes and other elements in the C language and C ++.



Determine the type of data elements which youyou want to store in the array. If you specify a numeric data are commonly used types: int, double, float, string - char. To create a one-dimensional array write a line like: int Massiv1 [5].


When working with a two-dimensional array, its creationIt looks like this: char Massiv2 [3] [4]. In the first case Massiv1 variable will contain the 5 elements of type int. In the second case - Massiv2 indicates a two-dimensional array having three rows and four columns containing elements of type char.


If you need to specify a linear arrayunknown size, note the similar form: char * Massiv3 []. In this case, the array will be allocated strictly defined amount of memory. Partly Massiv3 will be a null pointer to be initialized. To do this, the variable is assigned a value once: char * Massiv3 [] = { «first element", "second element," "third element"}.


To create an array containing objectsstructure, first set the type of the structure. For example, there is a kind of structure: struct ASD {int a- const char * b-}. Here, a new type of ASD, containing two standard data types. Further, it can already be used to create new arrays. And the array will also contain elements with two, two standard types: int and string to char pointer.


Create an array of developed structure. To do this, imagine a new structure as the type and write the expression: ASD Massiv4 [6]. There is a type of ASD, Massiv4 - is the name created an array containing six elements of type ASD. Similarly, there is a creation of the array for any possible data types.

How to make an array

Comments are closed.