Ladder

### Arrays C arrays can be tricky since we can represent them using the `[]` syntax or as pointers using the `*` syntax. In the case of the `[]` syntax -

We can access elements by using the familiar `arr1[index]` syntax

In the case of the pointer `*` syntax - `malloc` returns a pointer to the start of a buffer that is the same size as the argument that is passed in - So, the value of `int *arr2` in this case is a pointer to the start of a buffer of size `12` -

Each `int` is 4 bytes and there are 3 of them

- We can access elements using pointer arithmetic and dereferencing - We can think of `arr2 + i` as a pointer that points to the location of the ith element - We can then get the value at that location by dereferencing it using `*(arr2 + i)` Pointer artihmetic (for example `arr2 + i`) is a little more subtle than this as shown by the print output - `arr2 + i` results in `i * sizeof(type(arr2))` bytes being added to `arr2` - In this case, `type(arr2)` is `int` and `sizeof(int)` is 4, which results in the increments of 4 in the output Why should we even use the pointer representation of arrays? - If we dynamically create our array and don't know the size ahead of time, we're forced to use `malloc`