C__DOCUME~1_MAXWID~1_LOCALS~1_Temp_plugtmp-27_lecture15_pointers

C__DOCUME~1_MAXWID~1_LOCALS~1_Temp_plugtmp-27_lecture15_pointers

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 1 ee312 Spring 2008 Lecture 15 1 Announcements Lecture 15 Read chapter 17 Topic for today pointers ee312 Spring 2008 Lecture 15 2 Why pointers? Reference Ch. 11 and 12 Power of direct manipulation of memory locations is crucial in many embedded and systems software applications Its faster to pass only a reference instead of a whole array or structure to a function We can split a string by inserting '\0' and do not loose the other half Pointers are required to do file IO Others later 2 ee312 Spring 2008 Lecture 15 3 ee312 Spring 2008 Lecture 15 4 Pointer Concepts (1) The pointer type supports indirect addressing A pointer holds a memory address rather than a value - what is at the memory address is the value of interest Basic unary operations are: & (the address of operator) and * (the indirection operator or contents at an address) Pointer variables have to be declared along with the type of data that they point to. E.g. int *p; /* means that pointer p must point to an int */ Dont use int* p; - its bad style Mixed type pointer manipulations are not allowed int *p; double *q; p = q; /* not allowed */ 3 ee312 Spring 2008 Lecture 15 5 Pointer Implementation Variables Memory A pointer variable(e.g. p) contains the memory address of another variable as its value p x 25 int *p = 0; /*set to NULL*/ int x: p = &x; x = 25; /* or *p = 25; */ printf("Value is %d \n", (*p) ); ee312 Spring 2008 Lecture 15 6 Pointer Concepts (2) The important concept here is that a pointer is a variable that contains an address....
View Full Document

Page1 / 8

C__DOCUME~1_MAXWID~1_LOCALS~1_Temp_plugtmp-27_lecture15_pointers

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

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