Pointers

Important: A pointer is nothing more than an address

A variable that stores the address of some value

A pointer typically takes up 8 bytes of memory in C

Memory

Disk drives are just storage space, manipulation and use of data can only take place in RAM.

Memory is basically a huge array of 8-bit wide bytes.

Different data types take up different amounts of bytes of RAM.

Interacting with Pointers in C

#include <stdio.h>
int main(void)
{
    int n = 50;
    int *p = &n; // Get the address of n in memory
    printf("%p\n", p); 
    printf("%i\n", *p); // Get what is stored at the address in p
}

NULL Pointer

Pointer that points to nothing.

If you try to dereference a NULL pointer (e.g., *<NULL pointer>), you’ll segfault, which is better than accidental dangerous manipulation of unknown pointers.