Pointers

suggest change

A pointer is an address that refers to a location in memory. They’re commonly used to allow functions or data structures to know of and modify memory without having to copy the memory referred to. Pointers are usable with both primitive (built-in) or user-defined types.

Pointers make use of the “dereference” * , “address of” & , and “arrow” -> operators. The ‘*’ and ‘->’ operators are used to access the memory being pointed at, and the & operator is used to get an address in memory.

Syntax

Be aware of problems when declaring multiple pointers on the same line.

int* a, b, c; //Only a is a pointer, the others are regular ints.

int* a, *b, *c; //These are three pointers!

int *foo[2]; //Both *foo[0] and *foo[1] are pointers.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents