Pointers

suggest change

A pointer stores the address of an object or function, or a special null pointer value. Pointers let code refer to objects without copying them and can point to both built-in and user-defined types.

Pointers commonly use the dereference (*), address-of (&), and member-access (->) operators. * accesses the pointed-to object, -> accesses one of its members, and & obtains an object's address.

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]; // foo[0] and foo[1] are pointers. *foo[0] is an int.

Pointer basics

Pointer operations

Pointer arithmetic

Feedback about page:

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



Table Of Contents