Table of Contents
show
Register Storage Class
- specifes that the access to the declared object should be as fast as possible
- The object of an identifier for which the register storage class has been specified is stored in central processing unit (CPU) register instead of memory.
- When an object is declared as register, the declared object will have local life time. Thus, it cannot be declared as global
- The variables specified with register storage class are not implicitly initialized. It has to be explicitly initialized else it will take garbage value
- It is not possible to compute address of an object whose identifier is declared with register storage class specifier
Example
#include<stdio.h>
#include<conio.h>
int main()
{
register int a = 200;
printf("a = %d\n",a);
{
int b = 300;
printf("b=%d \n",b);
printf("Here a = %d \n",a);
}
printf("Now a = %d \n",a);
return 0;
}
Output
C:\TDM-GCC-64>gcc register.c -o register
C:\TDM-GCC-64>register
a = 200
b=300
Here a = 200
Now a = 200
Views: 0