The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
On using register keyword we are forcing the compiler not to use memory to store the data instead use CPU register.
Accessing register variable executes faster than auto variable.
One cannot dereference register variable because it has not any memory address.
Now the equation is straight forward, one cannot comes out with pointer concept using register variable.
register int m;
Let's workout a program to demonstrate register storage class in C.
#include <stdio.h> int main() { int m1 = 5; register int m2 = 10; printf("The value of m1 : %d ",m1); printf("\nThe value of m2 : %d ",m2); return 0; }
The program illustrates that, the register variable is declared and initialized inside the main function.
Keyword | register |
Storage Type | register |
Scope | Block Scope |
Life Time | Static lifetime |
Visibility | Global/Local |
Default Value | Garbage value |
Default Storage Class | No |
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019