Pointer Arithmetic

When doing pointer arithmetic, the adding value will be based on the type of pointer

For example if we have this:

#include <stdio.h>

int main() {
    int *ptr;
    printf("Pointer is %p, pointer value is %d\n", ptr, *ptr);
    printf("nextPointer is %p, pointer value is %d\n", ptr + 1, *(ptr + 1));
}

In here, since our pointer is an int which of size 4. It will be +4 when we do ptr + 1

Pointer is 0x1004d5b90, pointer value is -401472408
nextPointer is 0x1004d5b94, pointer value is 1

It's because from address 0x1004d5b90 it's reserved 4 bytes for the current int, therefore the next int would be at 0x1004d5b94.