C Pointers
A pointer is a variable that holds an address
Passing pointers as arguments
Pointers and Arrays
- When a pointer is assigned to an array, it points to the first element of the array.
- Array/Pointer Equivalence in function calls
- Changing arrays in functions
Void pointer
- Sometimes it’s useful to have a pointer to a thing that we don’t know the type of.
- Example use case:
- This function copies n bytes of memory starting from address s2 into the memory starting at address s1. With the
void *
type, we can use this function to copy any type.
- A more practical example:
Pointers to Pointers
- When we use pointer as an argument in function, only changes in where this pointer is pointing at