2012Week03Lecture3

cannot be applied to expressions constants or

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: c is a char and p is a pointer of type char, then the pointer p is poin1ng to the char c. •  The memory cell p contains the address of the variable c. •  We declare a pointer p, p: c: char *p; 5 Pointers and Addresses (cont’d) •  Recall the unary operator &, that gives the address of an object: –  & only applies to objects in memory, such as variables and array elements. –  & cannot be applied to expressions, constants, or register variables. •  So the statement: p = &c; assigns the address of c to the variable p. p is said to “point to” c. 6 Pointers and Addresses (cont’d) •  The unary operator * is the indirec'on or dereferencing operator. •  When applied to a pointer, it accesses the value the pointer points to....
View Full Document

Ask a homework question - tutors are online