Continued articles function
All arrays are composed of contiguous memory locations. The lowest address corresponds to the first element, the highest address corresponding to the last element.
To declare an array in C ++, and the number of elements of the specified element of the type required, as follows:
type arrayName [ arraySize ];
In C ++, you can initialize the array one by one, you can also use an initial statement, as follows:
double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};
The number of elements in the initialization If you omit the size of the array, the array size was. Therefore, if:
double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};
The first address array element of the array is the address of the array (learned assembly language knows here will apply for a segment of the memory segment address is the address of the array)
setw (13) width is provided
C ++ supports multidimensional arrays. The general form of a multidimensional array declaration is as follows:
type name[size1][size2]...[sizeN];
Multi-dimensional array can be initialized to the specified values in each row in parentheses. The following is an array with three rows and four columns.
int A [. 3] [4] = {
{0, 1, 2,. 3}, / * initialize the index number of rows 0 * /
{4, 5, 6, 7}, / * initialize the index number of row 1 * /
{8, 9, 10, 11} / * initialize the index number of the row 2 * /};
Nested inside parentheses is optional, the following initialization is equivalent to the above:
int a [3] [4] = {0,1,2,3,4,5,6,7,8,9,10,11};
array pointer
In C ++, a char * or char [] is transmitted to cout outputs, the result will be the entire string, if you want to get the address of the string (a character of the first memory address), the following methods may be used:
Forcibly converted to other pointer (non char * ). May be void *, int *, float * , double * and so on. * Use & s [0] is not output S [0] (first character) address. Because & s [0]
The return char * , for char * ( char pointer), COUT will be treated as a character string, a character look down and until the end of the output character *.