



The caret dereferences the pointer that is, it returns the value stored at the memory address held by the pointer. When the caret symbol appears after a pointer variable: The caret symbol denotes a type that represents pointers to variables of type typeName. When it appears before a type identifier: The caret symbol ^ has two purposes, both of which are illustrated in our example. For more information, see The Operator and Procedural Types in Statements and Expressions. The operator, which is used here to take the address of a variable, also operates on functions and procedures.
Free pascal pointer record array code#
After this code executes, X and Y have the same value, namely 17. Finally, line 7 retrieves the value at the location pointed to by P (denoted by ^P) and assigns it to Y. Line 5 assigns a value to X, and line 6 assigns the address of X (denoted by to P. Line 3 declares P as a pointer to an Integer value this means that P can point to the location of X or Y. Line 2 declares X and Y as variables of type Integer. To see how pointers work, look at the following example:Ģ X, Y: Integer // X and Y are Integer variablesħ Y := P^ // dereference P assign the result to Y Declaring and using the pointer types supported by Delphi.This topic contains information on the following: On 64-bit platforms, a pointer occupies eight bytes of memory as a 64-bit address. On 32-bit platforms, a pointer occupies four bytes of memory as a 32-bit address. The PByte type is used for any byte data that is not character data. The general-purpose Pointer type can represent a pointer to any data, while more specialized pointer types reference only specific types of data. Pointers are typed to indicate the kind of data stored at the addresses they hold. If that address is already taken, then the pointer holds the address to the first element. In the case of an array or other structured type, a pointer holds the address of the first element in the structure. When a pointer holds the address of another variable, we say that it points to the location of that variable in memory or to the data stored there. Go Up to Data Types, Variables, and Constants IndexĪ pointer is a variable that denotes a memory address. 1.1 Using Extended Syntax with Pointers.
