What is a register variable
Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a registervariable is local to the block in which it is defined. Lifetime is till control remains within the block in which the
register variable is defined. Variable stored in a CPU register can always be accessed faster than the one that isstored in memory. Therefore, if a variable is used at many places in a program, it is better to declare its storage class as register
Example:
register int x=5;
Variables for loop counters can be declared as register. Note that register keyword may be ignored by some
compilers.
Variables for loop counters can be declared as register. Note that register keyword may be ignored by some
compilers.
No comments:
Post a Comment