L11 - 11 POINTERS Pointer Variables • Each variable in a...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 11. POINTERS Pointer Variables • Each variable in a C program occupies space in memory during its lifetime: • The address of a variable is the address of its first byte in memory. • A pointer variable is a variable capable of storing the address of (“pointing to”) another variable. Pointer Variables • When a pointer variable is declared, its name is preceded by an asterisk: int *p; The * indicates that p is not an integer variable, but rather a variable capable of pointing to an integer. • Each pointer variable can point only to objects of a particular type: int *p; /* points only to integers */ float *q; /* points only to float values */ char *r; /* points only to characters */ • Before it has been assigned a value, a pointer points to nothing in particular. The Address Operator • A pointer can be given a value by assigning it the address of a variable. To determine the address of a variable, use the address operator (represented by the & symbol): int i, *p; p = &i; After this assignment, p “points to” i : The Indirection Operator...
View Full Document

Page1 / 16

L11 - 11 POINTERS Pointer Variables • Each variable in a...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online