Pointers and Arrays

Certain VTS functions (such as New), return pointers. The New function is typically used to allocate an array. For example:

ArrayPtr = New(1 { Number of dimensions },

0 { Starting index }, 

10 { Number of elements }); 

To use an element from "ArrayPtr", you must dereference the element:

(*ArrayPtr)[0] = 5;

The array index operator [ ] automatically performs a pointer dereference operation if the variable before the array index operator has a pointer value. For example, the expression above can also be written as displayed below to achieve the same result.

ArrayPtr[0] = 5;

The preferred method is to allow the array index operator to automatically perform the dereferencing of the pointer, as it improves the readability of the statement, requires less memory, and executes faster.