1402 20.5 - COMP1002/1402 Chapter 20 Writing Generic Code 3...

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

View Full Document Right Arrow Icon
3/24/2010 1 COMP 1002/1402 Introduction to Systems Programming Chapter 20 Suppl.: More on Pointers to Void and to Functions Pointers to void Creates “generic” pointers. Programmer is responsible for their proper use. COMP1002/1402 - Chapter 20: Writing Generic Code 2
Background image of page 1

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

View Full Document Right Arrow Icon
3/24/2010 2 Using Pointers to void Important : a pointer to void cannot be dereferenced unless it is cast. void *p; int i=7; p = &i; printf(“%d\n”, *p); //ERROR! printf(“%d\n”, *((int*)p)); //OK!
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COMP1002/1402 - Chapter 20: Writing Generic Code 3 Pointers to Functions • Points to a function loaded in memory. COMP1002/1402 - Chapter 20: Writing Generic Code 4 3/24/2010 3 Defining a Pointer to a Function • We define our function pointers almost the same way we define our function prototypes. • We need the return type of the function and its parameter types. COMP1002/1402 - Chapter 20: Writing Generic Code 5...
View Full Document

{[ snackBarMessage ]}

Page1 / 3

1402 20.5 - COMP1002/1402 Chapter 20 Writing Generic Code 3...

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

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