C Programming Language: Arrays and Dynamic Allocation

C Programming Language: Arrays and Dynamic Allocation

Math 230 Assembly Language Programming

(Computer Organization) Thu Jan 23, 2008 Lecture 4

Learning Objectives

? Pointer Review, and call-by-reference

? Array Names as Pointers

Indirect referencing: Convert integer indexed array notation to pointer notation

? Pointer Arithmetic

Use pointers vs indices for array processing

? Passing and Using Array Addresses

pointer declaration vs standard for formal parameter

? Dynamic Memory

1d, 2d

2

Easy Steps to Pointers

? Step 1: Declare the variable to be pointed to

int num; char ch = `A'; float x;

num: ch: `A' x:

3

Easy Steps to Pointers (cont)

? Step 2: Declare the pointer variable

int num; char ch = `A'; float x;

int* numPtr = NULL; char *chPtr = NULL; float * xPtr = NULL;

numPtr: chPtr: xPtr:

num:

NULL NULL NULL

ch: `A'

x:

4

Easy Steps to Pointers (cont)

? Step 3: Assign address of variable to pointer

int num; char ch = `A'; float x;

int* numPtr = NULL; char *chPtr = NULL; float * xPtr = NULL;

numPtr: chPtr: xPtr:

num: ch: `A' x:

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download