Array

From GMpedia.org Wiki

Jump to: navigation, search

An array is a collection of variables of the same type.

The elements of an array can be accessed by using the index operator [] ( () in Visual Basic) with their index. Index numbering starts at 0.

[edit] Examples in C / C++

int a[7]={45,28,34,17,12,39,78}; //declaration and initialization of a one-dimensional array of ints
double b[2][6]={{25.8,19.7,24.2,12.2,79.4,57.1},  //declaration and initialization of a
                {38.7,27.8,16.4,13.1,48.3,20.0}}; //two-dimensional array of doubles

In the first example, the 7 between the []'s is not necessary since the compiler can determine the number of items.

[edit] Examples in Visual Basic

Dim a() as Integer = {45,28,34,17,12,39,78}

Dim b(,) as Double = {{25.8,19.7,24.2,12.2,79.4,57.1},{38.7,27.8,16.4,13.1,48.3,20.0}}

In both examples, the compiler can determine the size of the array.

This article is a stub, please help GMpedia expand it.
Personal tools