The register keyword in C language and the register keyword
The variable modified by register in C language indicates that the variable is stored in the CPU register. Because the CPU access register is much faster than the access memory, the operation speed can be greatly improved. Note the following when using register.
1. The variable modified with register can only be a local variable, not a global variable. The CPU register resources are limited, so it is impossible for a variable to occupy the CPU register all the time.
2. The register variable must be a value acceptable to the CPU.
4. You cannot use the & operator to retrieve the address of the register variable.
5. register only requests register variables and may not succeed.
Keyword in C language of the Computer: What is register?
Register is a register type. That is to say, if a variable is defined, it is first considered to be put into a register, but there are so many registers. If it is used up, it will be placed in the memory. That is to say, the register type is defined with the definition, but not necessarily stored in the register.
Keyword in C language of the Computer: What is register?
Register
You can use the register modifier to declare that an object has an automatic life cycle. Therefore, register can only be used in the declaration of a function.
This keyword tells the compiler that the access to this object should be as fast as possible, and it is best to store it in the CPU register. However, the compiler does not necessarily do this.
In addition, when an object is declared as register, the address operator & is unavailable because it may be put into registers.