325 views
2 votes
2 votes
please explain the memory allocation of statement , means how it works

register int a= 10;

1 Answer

Best answer
0 votes
0 votes

SO register a=10 means we are giving value of a=10 to registers   but it doesnt mean that register will store this value . we are just giving this value storing this depends on whether registers are free and many other factors 

OTHER FACTORS HERE ARE 

1) if we use & with register variable  means we are going to access address here . then some compiler show error or some warning.

as we dont access register address. It is invalid.

register int i = 10;

  int *a = &i; it is invalid

2)REGISTER is a storage class . in c we cant use multiple storage classs at a time.

means we cant use static register int a : it is invalid

 

3) we cant put *with register variable

 register int *a = &i; it is valid

we can use give ass no. of registers commands but only access to few

CREDIT ;  

Somoshree Datta 5  The register declaration can be applied only to automatic variables and formal parameters of a function.

 


 

selected by

No related questions found