In this code, I'm confused about some of the syntax. For example...
I'll try and address these one at a time ( no pun intended )
what does int* p
This declares a local variable called 'p' who's type is a pointer to an int. Thus when this variable is assigned to a memory address it will read 4-bytes as if they were an int32.
... and p = &a
The '&a' on the right is read as "the address of a", meaning take the memory location we assigned to the local variable 'a'. Assigning this to the already declared int pointer, 'p', we can then read 'p' to get the value actually stored in the variable 'a'.
And the last part with the fixed (int* r = ia), what does that do?
This is very similar to the assignment of p to the address of a except there is not an "the address of" prefix. This is because the type of the variable 'ia' is an array which is being treated implicitly as if it were a pointer. Thus this statement declares an int pointer 'r' and assigns it to the address of the first item in the array 'ia'.
Here are a few more notes:
if (*p == 2) ...
A pointer prefixed with the '*' will dereference that pointer and be treated as if it were a variable of the type of pointer. Thus in our example dereferencing 'p' who points to the variable 'a' will result in the value stored in 'a', 2.
*p = 100;
Just like reading a value at the address pointed to by 'p', we can also write a new value. Simply dereference the pointer and assign it a new value.
*&a
This is just intended to confuse someone. As explained it takes the address of 'a' by prefixing '&', but then dereferences the address with the '*' prefix. This simply evaluates to 'a' and both prefixes can be omitted without a change in behavior.