Corrected grammatical errors. (#18390)
This commit is contained in:
@ -5,7 +5,7 @@ title: C++ Arrays
|
|||||||
## What are Arrays?
|
## What are Arrays?
|
||||||
An array is a series of elements of the same data type which are stored in contiguous memory locations and can be referenced individually.
|
An array is a series of elements of the same data type which are stored in contiguous memory locations and can be referenced individually.
|
||||||
|
|
||||||
For example, a array containing 5 integer values called numbers is declared like so:
|
For example, an array containing 5 integer values called numbers is declared like so:
|
||||||
```C++
|
```C++
|
||||||
int numbers [5];
|
int numbers [5];
|
||||||
```
|
```
|
||||||
@ -24,10 +24,10 @@ int numbers [] = {1, 2, 3, 4, 5};
|
|||||||
//In the examples above, the size was fixed beforehand
|
//In the examples above, the size was fixed beforehand
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note** that arrays in C++ are not permutable in size, which means that once you've declared a array with size 5 it cant be enlarged or made smaller. In case you really need a bigger array with the same entries, you would have to copy all entries to a new array of bigger size.
|
**Note** that arrays in C++ are not permutable in size, which means that once you've declared a array with size 5, it can't be enlarged or made smaller. In case you really need a bigger array with the same entries, you would have to copy all entries to a new array of bigger size.
|
||||||
|
|
||||||
### Access:
|
### Access:
|
||||||
Elements from an array can be accessed via reference of theire position in the array. (Start counting from 0).
|
Elements from an array can be accessed via reference of their position in the array. (Start counting from 0).
|
||||||
Example:
|
Example:
|
||||||
```C++
|
```C++
|
||||||
x = numbers[0]; // = 1. [0] == first position
|
x = numbers[0]; // = 1. [0] == first position
|
||||||
|
Reference in New Issue
Block a user