Home > Backend Development > C#.Net Tutorial > How to define an array in c++

How to define an array in c++

王林
Release: 2020-06-19 14:42:53
Original
13282 people have browsed it

How to define an array in c++

If you want to declare an array in C, you need to specify the type of elements and the number of elements, as follows:

type arrayName [ arraySize ];
Copy after login

arraySize must be an integer greater than zero Constant, type can be any valid C data type.

(Recommended tutorial: C Language Tutorial)

For example, to declare an array balance of type double containing 10 elements, the declaration statement is as follows:

double balance[10];
Copy after login

Now balance is an available array that can hold 10 numbers of type double.

Specific elements in an array can be accessed by index. All arrays are composed of contiguous memory locations. The lowest address corresponds to the first element, and the highest address corresponds to the last element.

The above is the detailed content of How to define an array in c++. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template