Is there anything wrong with the following code?


main( )

{

int i = 10 ;

register *p = &i ;

printf ( “%d”, *p ) ;

}

Ans: Nothing is wrong with the program. p is declared as a pointer to a register int (as int is default type). By this declaration address of the variable is going to be stored in CPU registers. The moral is that we can also store pointers i.e addresses in registers.

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers