1 2 3 4 5 6

Review of Pointers and Addresses

*C has a simple memory model. Blocks of memory are organized as a sequence of bytes which can be manipulated individually or in contiguous groups.
*Each byte of memory has an address.

An addresses is stored in a pointer.

*Each datatype requires one or more bytes to store it. Typically a character requires one byte, an integer requires 2 or 4 bytes, a double usually take 8 bytes, and so on. It follows that not every byte address is a legitimate address of a data object.

Consider how we exchange two values in memory. For the quantities a and b, we would simply write
float a, b;
float t;

t = a; a = b; b = t;

*However, if we want to do the same thing inside a procedure we would have to pass the addresses of aand bas actual parameters, as follows

swap( &a, &b );

January 21, 1999

Page2

JH/TM