Where are the auto variables stored? What is the use of register variables?

Showing Answers 1 - 3 of 3 Answers

Nadeem Yousuf

  • May 4th, 2006
 

 Auto variables are stored in memory and their default value is a garbage value. Register variables are meant to be stored in processor registers.

for instance if we write  register int i;  then i should be stored in a register. it may or may get the place in a register depending upon whether there are sufficient registers available or not because in microcomputers there are usually 14 to 16 registers and they may be engaged in some other work.

also one should remember that these registers are 16 bit so these statements should be avoided   register float i , register double j . the compiler wont show any error and will take them as auto.

  Was this answer useful?  Yes

neetu

  • May 8th, 2006
 

to be specific auto variables are stored in stack

  Was this answer useful?  Yes

shaanxxx

  • Aug 20th, 2006
 

By saying register to a Variable , you are just suggesting the compiler put in register.Compiler is the best person to decide, which var will go in register. I believe , we should not use register , it may confuse compiler.auto is just stack variables, thats it.one more thing we missed out, 'volatile'. compiler never keep volatile in register .:)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions