Ladder

### Pointers (Referencing and Dereferencing) In this class, we'll be dealing a lot with pointers in our programming assignments since they're inherent to C. A pointer is an address. It tells us where a value is located. We can get a pointer to a variable or the address of a variable by using the `&x` syntax if `x` is our variable. Why are pointers useful? Well, if I pass you a pointer to my `int x` variable such as the `int *y` pointer, you can change the value of my local variable `x` using the `*y = 5;` syntax. - `&x` is called "referencing" because we are getting a reference to the variable `x`. - `*x` is called "dereferencing" because we are getting the value that the reference refers to. Let's analyze the code - We can declare a pointer type by using the `{type} *{var_name}` syntax. - We can get a reference or address of a variable by using the `&x` syntax. - The function `modify1` takes in an integer. We see here that the function *DOES NOT* modify the value of `x`. - The function `modify2` takes in a pointer to an integer. We see here that the function *DOES* modify the value of `x` because `*y = 5` assigns the value of `5` at the location specified by `y`. In this case the location specified by `y` is where `x` lives. - Furthermore, we see that `x`'s value is changed as well because `y` points to `x`.