In pointer arithmetic, if you do arithmetic (addition, substraction, etc.) on the pointer, the compiler auto scales that aritmetic by the size of the data type the pointer points to:
int *p = (int*) 100;
p++;
printf("%d", p); // p becomes 104, because sizeof(*p) = 4
Auto scaling is why you don’t give any mind to the size of data types when traversing arrays, and so on.
If you did have to mind the size of data types, traversing an integer array (without autoscaling) would look like so:
#include <stdint.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
int a[] = {1, 2, 3};
for (int i = 0; i < 3; i++) {
// NOTE: sizeof(char) = byte
// allows for byte traversal, where
// we can take a look at underlying pointer
// arithmetic
printf("%d", *(int *)((char *)a + i * sizeof(a[0])));
}
}
which looks very cool, but would be a pain if we have to do it every time.