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

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

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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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

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.

## 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
Ask a homework question - tutors are online