08 04 86 43

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: nter. For example, the malloc function returns a generic pointer, which is converted to a typed pointer via a cast (line 21). ¯ ¯ Every pointer has a value. This value is an address of some object of the designated type. The special NULL (0) value indicates that the pointer does not point anywhere. We will see the values of our pointers shortly. Pointers are created with the & operator. This operator can be applied to any C expression that is categorized as an lvalue, meaning an expression that can appear on the left side of an assignment. Examples include variables and the elements of structures, unions, and arrays. In our example code, we see this operator being applied to global variable g (line 24), to structure element s.v (line 32), to union element up->v (line 33), and to local variable x (line 42). Pointers are dereferenced with the * operator. The result is a value having the type associated with the pointer. We see dereferencing applied to both ip and *ip (line 29), to ip[1] (line 31), and xp (lin...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online