Sunday, July 12, 2009

In C when we write int i; does compiler reserve memory for i? What if we specify the storage class and define?

does compiler reserve memory when we declare


static int i;


register int i;

In C when we write int i; does compiler reserve memory for i? What if we specify the storage class and define?
In all three cases, the compiler will reserve memory for the variable. The register keyword will attempt to store on the CPU register which if not available will store the memory on the heap.
Reply:In all three cases, the compiler will reserve memory for the variable.


the static variable will store the value in the reserve memory till program terminates


The register keyword will attempt to store on the CPU register which if not available will store the memory on the heap.
Reply:"The register keyword will attempt to store on the CPU register which if not available will store the memory on the heap."





no, on the stack!

wildflower

No comments:

Post a Comment