introC_lec9 - 9/23/2010 Computer Programming for...

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

View Full Document Right Arrow Icon
1 Computer Programming for Engineering Applications ECE 175 Intro to Programming Limitations of Reference by Value Write a C function that does the following Argument: the radius of a circle r Output: circumference c and area a 9/23/2010 ECE 175, Spring 2010 2 Reference by value does not allow the manipulation of variables external to the function!!! Pointer: A label used to refer (point) to particular content Very frequently found in real life Page numbers in a book, or powerpoint slides Page numbers are pointers to the contents of the particular page The Concept of Pointers 9/23/2010 ECE 175, Spring 2010 3 Mail boxes at the post office Numbers are used to label each mailbox. The contents (letters) of a particular mailbox can be retrieved by referring to the mail box number. The Concept of Pointers 9/23/2010 ECE 175, Spring 2010 4 Labels for referencing memory addresses Pointers in C 9/23/2010 ECE 175, Spring 2010 5 45 678 3.36 ‘a’ 112 5.83 1 2 3 4 5 6 Address Contents Lack of support of basic functionality for arrays, strings and data structures In fact when you use arrays and strings you disguisedly use pointers! Faster memory access and usage via memory referencing Critical back in the 70s when the language was developed Still required for programming resource constrained devices such as microcontrollers Saving memory space No need to hold local copies of variables inside function Can pass values to a function by reference Downside Pointers usually make program tracking/reading more complicated Why do we need pointers? 9/23/2010
Background image of page 1

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

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

This note was uploaded on 11/06/2010 for the course ECE 175 taught by Professor Grubbs during the Spring '08 term at University of Arizona- Tucson.

Page1 / 5

introC_lec9 - 9/23/2010 Computer Programming for...

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

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