What is an Address?

What are the numbers? What does it do? Is the address the location of the val inside the program?

It’s a memory address some point in memory.

I assume you mean something like 0xDEADBEEF or 0x4F1BE900.

Just like houses on a road have numbers starting with 1 going upwards, each represents one memory location in your RAM, starting from 0x00000000 (=0 = 2^0) up to 0xFFFFFFFF (=4294967295=2^32-1=approx. 3.8 GB, https://en.wikipedia.org/wiki/3_GB_barrier) on 32-bit systems (64-bit can store more).

Each memory slot typically stores 1 byte (8 bit). Depending on your variable, more than 1 memory location is needed to store it, in which case the computer picks a location where enough consecutive addresses are unused, the address then refers to the first location.

These are what pointers represent in e.g. C++. The CPU is the craftsman, you give him an adress and tell him what work needs to be done. It goes there, does the work, and leaves.

Edit:
32-bit systems :

  • Since one Ram location stores 1 byte the max RAM size was about 3,8GB which was a problem

  • Same goes for Harddrives: one location stores 512 byte, with 0xFFFFFFFF locations that amounts to 2TB

1 Like

Privacy & Terms