cs246-tutorial-02

cs246-tutorial-02 - CS 246 Tutorial 2 Peter Beshai Spring...

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

View Full Document Right Arrow Icon
CS 246 Tutorial 2 Peter Beshai Spring 2009 1 Review of Pointers We know that variables are stored in memory. With typical variables, we need not concern ourself with what their actual memory addresses are. However, there are often times when we want to work with data through the use of memory addresses, and for these uses we have pointers . A pointer is a variable whose value is a memory address. 1.1 Declaring Pointers The only difference between declaring a pointer and a regular variable is that we must preface the variable name with a * . The type that is specified denotes the type of data that the pointer points to. For example, int *x denotes an pointer x which points to an int in memory. 0x3e0f4348 x: ??? 0x3e0f4348 ... ... Memory 0x6ca805a4 ... Figure 1: Declaring Pointer Example 1.2 Operators There are two operators we need to be aware of when working with pointers: * and . 1.2.1 The Dereference Operator * The * operator is used for dereferencing pointers. This means that the memory address stored in a pointer
Background image of page 1

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

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

This note was uploaded on 01/19/2010 for the course CS 246 taught by Professor Wormer during the Spring '08 term at Waterloo.

Page1 / 6

cs246-tutorial-02 - CS 246 Tutorial 2 Peter Beshai Spring...

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

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