CS31-8

CS31-8 - CS 31 Introduction to Computer Science I Topic 8 Pointers CS 31 Introduction To CS I Topic 8 Pointers 9/2009 John A Rohr All Rights

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

View Full Document Right Arrow Icon
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-1 CS 31 : Introduction to Computer Science I Topic 8 Pointers
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-2 Pointers Character Constants Character constants are instances of specific characters d 9 @ e 4 A r z J
Background image of page 2
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-3 Pointers Character Variables Character variables hold character constants in memory char c1 = '7'; 10000 char c2 = 'j'; 10001 char c3 = '#'; 10002 char c4 = 'R'; 10003 char c5 = '4'; 10004 7 j # R 4
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-4 Pointers Integer Constants Integer constants are instances of specific integer values 4937 -536 396 36 -5 0 4 1234 -683 58
Background image of page 4
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-5 Pointers Integer Variables Integer variables hold integer constants in memory int i1 = 21; 200 int i2 = -729; 204 int i3 = 424; 208 int i4 = 0; 212 int i5 = 816; 216 000 424 -729 021 816
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-6 Pointers Storage of Variables Variables are stored in memory locations The memory location of a variable is called the address of the variable Although the address of a variable is an integer number, it is not integer data The address specifies a place, not a value
Background image of page 6
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-7 Pointers Pointer Concept A number which specifies the address of a data item is called a pointer to the data Although the number is an integer number, it is not integer data but a memory address Pointer and integer data are different types of data: a place as opposed to a value
Background image of page 7

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

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-8 Pointers Pointer Constants A pointer constant is a specific instance of a pointer which holds the address of a specific variable in memory The pointer constant is said to point to the variable at its memory location
Background image of page 8
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-9 Pointers Pointer Constants Pointer constants are instances of specific pointer values 46 9475 2964 720 95 1234 4 1234 52 538
Background image of page 9

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

View Full DocumentRight Arrow Icon
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved JAR 8-10 Pointers Pointer Variables Pointer variables hold pointer constants in memory which point to other data int i1 = 21; 200 int *p1 = &i1; 160 int i2 = -729; 204 int *p2 = &i2; 164 int i3 = 424; 208 int *p3 = &i3 168 int i4 = 0; 212 int *p4 = &i4 172 int i5 = 816; 216 int *p5 = &i5 176 000 424 -729 021 816 212 208 204 200 216
Background image of page 10
CS 31: Introduction To CS I Topic 8: Pointers 9/2009 John A. Rohr All Rights Reserved
Background image of page 11

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

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

This note was uploaded on 10/08/2011 for the course CS 31 taught by Professor Melkanoff during the Fall '00 term at UCLA.

Page1 / 92

CS31-8 - CS 31 Introduction to Computer Science I Topic 8 Pointers CS 31 Introduction To CS I Topic 8 Pointers 9/2009 John A Rohr All Rights

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

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