Technically speaking, the C standard ensures that sizeof (char) == 1 and the rest is up to implementation. But on modern x86 architectures (e.g. Intel / AMD chips) this is pretty predictable.
You have probably heard that processors are described as 16-bit, 32-bit, 64-bit, etc. This usually means that the processor uses N-bits for integers. Since pointers store memory addresses and memory addresses are integers, this effectively tells you how many bits will be used for pointers. sizeof is usually measured in bytes, so code compiled for 32-bit processors will report the size of pointers 4 (32 bits / 8 bits per byte), and code for 64-bit processors will report the size of pointers 8 (64 bits / 8 bits) per byte). In this case, the limitation of 4 GB of RAM for 32-bit processors comes from - if each memory address corresponds to a byte, to access more memory you need integers in excess of 32 bits.
In practice, pointers will be size 2 on a 16-bit system (if you can find it), 4 on a 32-bit system and 8 on a 64-bit system, but nothing will come of using the given size
Shobhit sharma
source share