Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Please explain the principle of assignment to people who really understand C language.
Please explain the principle of assignment to people who really understand C language.
& amp

This is called recording the address,

Then & Num must be a memory address. Memory address must be an integer.

Internationalorganizations (same as international organizations)

*ptr

=

#

Where int*

The pointer type must also be an address, or an integer. These two data types are consistent and can be assigned values.

Int is above you

a

=

5;

The types of 5 and A mentioned in this sentence are inconsistent. This sentence is wrong, the type is the same. Your mistake is that you think 5 is an integer and A is a character.

Actually, it's not like this

Internationalorganizations (same as international organizations)

a;

It means to define a variable, the type of which is int, that is to say, I have now opened up a 4-byte space in the memory, which is represented by A. The content stored in these 4 bytes is 0 10 1, which is the complement of the binary code of 5, and all the places behind it can be represented by A.

This A is actually stored in memory, which is also divided into heaps and stacks. Then put A in the stack and 5 in the heap. A in the stack has a link directly to the space of 5 in the heap. The essence of the link is the first address 0 10 1 in the A storage stack in the stack. Reading will start from the first address and read 4 bytes in turn.

Do you understand?

The type of A is int, A is just an identifier, not an object, and the object is typed. You can understand that C language has no objects, but you can also understand that everything in the stack is an object and everything in the stack is an identifier.