Purpose of "register" keyword

What is the purpose of "register" keyword?

It is used to make the computation faster.

The register keyword tells the compiler to store the variable onto the CPU register if space on the register is available. However, this is a very old technique. Today's processors are smart enough to assign the registers themselves and hence using the register keyword can actually slowdown the operations if the usage is incorrect.

The keyword ‘register’ instructs the compiler to persist the variable that is being declared , in a CPU register.

Ex: register int number;

The persistence of register variables in CPU register is to optimize the access. Even the optimization is turned off; the register variables are forced to store in CPU register.
Explain the use of "auto" keyword
When a certain variable is declared with the keyword ‘auto’ and initialized to a certain value.....
C function prototype
A function prototype is a mere declaration of a function. It is written just to specify that there is a function.....
Purpose of "extern" keyword in a function declaration
The declaration of functions defaults to external linkage. The only other storage class possible for a function is static....
Post your comment
Discussion Board
register variable
a register keyword is used when a variable is more repeatedly used to increase performance
since register are closer to CPU then memory but still its not necessary a variable declared by keyword register will be allocated in register if register are busy doing some task they are placed in memory as auto variables
uma mahesh 02-1-2013