COMPSCI 61C Lecture Notes - Lecture 4: Dereference Operator
Document Summary
Consider memory to be a single huge array. Each cell of the array has an address associated with it. For addresses, we use unsigned numbers (negative addresses don"t make sense) [note] do not confuse the address referring to a memory location with the value stored there. An address refers to a particular memory location. Pointer: a variable that contains the address of the variable. How to get a value pointed to: * Java and c pass parameters by value (they copy the parameter, so the copy cannot change the original) How can we get a function to change the value held in a variable? void add_one (cid:383)int *p(cid:384) { Pointers can point to any kind of data (int, char, struct, etc. ) Normally, pointers can point to only one type void* is a type that can point to anything (generic pointer) [note] try not to use void to avoid program bugs, security issues, etc.