LEC20081009

# LEC20081009 - Introduction to Computer Programming October...

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

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Introduction to Computer Programming October 9, 2008 CSC180 Fall 2008, University of Toronto Pointer variables • Two things to remember about a pointer variable: 1. A pointer variable, like non-pointer variables, is put in memory at an address. 2. A pointer variable’s value is an address. • Example: int i, *p; /* both i and p are put in memory */ p = &i; /* assign i’s address to p */ CSC180 Fall 2008, University of Toronto 1 0xbff2cebc | p = 0xbff2cec0 | (p occupies 4 bytes) 0xbff2cebd | | 0xbff2cebe | | 0xbff2cebf | | 0xbff2cec0 | i | (i occupies 4 bytes) 0xbff2cec1 | | 0xbff2cec2 | | 0xbff2cec3 | | • p ’s address is 0xbff2cebc , and i ’s address is 0xbff2cec0 . p contains the address of i , 0xbff2cec0 . • Since p contains the address of i , we can simplify the above picture: _ _ |p|--->|i|-- CSC180 Fall 2008, University of Toronto 2 • Each box above represents an object in memory. The arrow shows that p points to i , i.e., p contains the address of i . *p gets the object pointed to by p , which is i ....
View Full Document

## This note was uploaded on 01/10/2011 for the course CSC 180 taught by Professor Na during the Fall '01 term at University of Toronto.

### Page1 / 14

LEC20081009 - Introduction to Computer Programming October...

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

View Full Document
Ask a homework question - tutors are online