Explain ‘register’ storage class.


main( )

{

register int a, *p1, *p2 ;

int b ;

clrscr( ) ;

p1 = &a ;

p2 = &b ;

printf ( “%u %u”, p1, p2 ) ;

getch( ) ;

}

Here, a is an integer variable, p1 and p2 are pointers. These all variables are of register storage class. This program would flash a compiler error because we are storing address of a register variable. Register variables don’t have address. However, it’s all right to store an address in a register variable. In other words, a register variable can be a pointer, but it can’t be pointed to.

This entry was posted in C Programming and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>