{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Discussion Notes 6

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

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

View Full Document Right Arrow Icon
EME 5 Fall 2006 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
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
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}