Discussion Notes 6

Discussion Notes 6 - EME 5 Fall 2006 Discussion 6 1....

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

View Full Document Right Arrow Icon
Discussion 6 1. Reasons for using pointers People say that one of the more important and distinguish characteristics of C as a programming language is its sophisticated use of pointers. People also say that the correct understanding and use of pointers is critical to successful C programming, since every real-world C program uses pointers. So, here are four main reasons for using pointers in our programs. (1) Pointers provide the way by which functions can modify their calling arguments. This means that by using pointers, we can pass addresses of variables to functions so that functions can change the value of these variables. (2) Pointers support C’s dynamic allocation routines. This means that by using pointers, we can work with memory that has been allocated dynamically. (3) Pointers can improve the efficiency of certain routines. (4) Pointers can directly access the computer’s hardware. 2. What are pointers? A pointer is a variable that holds the address of a memory location. Whenever we declare a variable, as in int i; the computer reserves a memory location for it. The computer might, for example, set aside memory location 1000 for i. Memory address Computer memory
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 04/21/2008 for the course EME 005 taught by Professor Cheng during the Fall '07 term at UC Davis.

Page1 / 8

Discussion Notes 6 - EME 5 Fall 2006 Discussion 6 1....

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