- This wiki is out of date, use the continuation of this wiki instead
Pointer
From FenixWiki
(Difference between revisions)
Revision as of 02:38, 13 May 2007 (edit) Sandman (Talk | contribs) ← Previous diff |
Revision as of 02:39, 13 May 2007 (edit) (undo) Sandman (Talk | contribs) m Next diff → |
||
Line 1: | Line 1: | ||
[[Category:language]] | [[Category:language]] | ||
[[Category:datatypes]] | [[Category:datatypes]] | ||
+ | [[Category:operators]] | ||
== Definition == | == Definition == |
Revision as of 02:39, 13 May 2007
Definition
POINTER
Pointers, are used to point to a location in memory. It uses 32 bits (4 bytes) so it can map 4GB of memory into bytes. Pointers can point to any datatype: ints, shorts, strings and even usermade datatypes.
Example
Program pointers; Private int my_int; int pointer my_int_pointer; Begin my_int_pointer = &my_int; my_int = 3; say(my_int); say(*my_int_pointer); *my_int_pointer = 4; say(my_int); say(*my_int_pointer); Loop frame; End End
The & (offset) operator, when used with pointers, returns a void pointer to a variable. In the example it returns an int pointer to the variable my_int. The * (pointer) operator, when used with pointers, makes it so the pointer variable is not accessed, but the variable it's pointing to. In the example it changes access from my_int_pointer to my_int.