Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Basics of C Programming
  5. Storage Classes
  6. Register Storage Class

Register Storage Class

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

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments