Memory, before we talk about memory, let’s talk about computers. When we talk about 500 gigabytes, we don’t really mean memory, we mean hard disk, and memory is usually 4 gb / 8 GB / 16 GB. The next level up is the cache and register.

Hard disk, memory, cache, register speed up in turn, cost increases, so naturally with less space. (Haha, back to the subject)

For example, in one area, a lot of houses have to be built. One day, a relative of the family came to join the family, but so many houses, no number, how to find it?

But if the house has a number, and relatives write down the number of the room on a slip of paper, isn’t it easy to find.

The house number is the address, and the room is the space.

Mapping relationship: Address > Space

How do you generate addresses? Computers have 32 bits and 64 bits that represent 32 address lines (data lines). When energized, positive and negative charges (1 and 0) are generated.

So it can be expressed as 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001 00000000 00000000 00000000 00000010.. …. 11111111 11111111 11111111 11111111

There are 2^32 addresses

Memory address Memory space 0 1 2 3 4… So how much storage does one memory use? 8 bit = 1 byte

If you use one memory space equal to one bit, 2^32 bit is about 0.5 GB, which is not only slightly different from 4G. If you use 1 memory space equal to 1 byte, which is 8 times the size of a bit, that is 4G, one memory space, one byte

Int a; 1 is equivalent to your online direct booking, said in advance of this position I want ~ (of course, the money can cover the venue)

a = 10; 1 In this space (room), put the number 10.

All right, this is like moving in. But we still have to deal with the house number (address). .

&a; 1 & is to take the address, but with the address we need a variable to accept it. This time we give a pointer variable to store the address.

int *p = &a; 1 * is not an operator, which means it is just a pointer variable.

One type of variable that holds an address is a pointer variable.

*p = 20; 1 is the dereference operator that can change the value of a through p ~~~

int *p; 1 also applies for a space on the memory address, and the corresponding memory space stores the memory address of A.

< to be continued >