ECS 30 Lecture Notes - Lecture 6: Static Variable, Global Variable, Ampersand
Document Summary
After a pointer is being assigned an object"s address the content is accessible via dereferencing operator (*). It is accessible for both reading and writing. The ampersand gets the address of the memory, and the * dereferences. It will change the content if you combine the two. Pointers need to reference something, to be dereferenced. If there is no object, then it is impossible to do and process crashes. The keyword null stands for a 0 in binary. If you place a pointer equal to null it will always be invalid. Dereferencing null always caused a segmentation fault error. Null is a reliable way to show a value is undefined. Some important usages for pointers are: output arguments for functions, arrays, and characters. When you give input into a function you are not giving the variables, you are giving the values only. Using memory addresses can help you to switch objects by swapping their memory addresses.