Pointers

Pointers - Notes 3: Pointers CSC 16, Spring 2008 Pointers...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 Notes 3: Pointers CSC 16, Spring 2008 Pointers double x = 0.25 int i = 10 char ch='B' Declaration of a variable => 1. A memory location corresponding to the size of the variable is reserved. 1 2. The name of the variable is associated with the address of that memory (address of the first byte). 3. The memory space is initialized to the value of the variable (if provided in the declaration). A double is 8 bytes, an int is 4 bytes and a char is 1 byte. Memory Address 0x100 0.25 0x108 10 0x10C B //############################ // Memory address of a variable //############################ Each variable is stored in a memory location with a particular address. The address of a variable can be found with the address // outputs the value of i followed by its memory address Address of x is: &x = 0x100 //######################## // C++ pointer variables //######################## A pointer variable is a variable whose value is a memory address. //#################################### // Declaration of pointer variables //####################################### VariableType *pointerVariable
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 // declares ptrVar as a pointer variable // that can store the address of a variable of type VarType. VarType *ptrVar = address What is the size of a pointer variable? Does it depend on the type a pointer variable can point to? Go over example 2.4. -> Show the address map
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

Pointers - Notes 3: Pointers CSC 16, Spring 2008 Pointers...

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

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