Skip to main content

Posts

Showing posts with the label Pointers

Pointers

A pointer variable is a variable that holds the memory address of another variable. They are called pointers for the simple reason that, by storing an address, they point to a particular location in memory. At the moment when a variable is declared, it must be stored in a concrete memory location. The programs do not decide where the variable is to be placed. That is done automatically by the compiler and the operating system at run time. The declaration   int x=3   tells the C compiler to         Reserve space in memory to hold the integer value.(location/address is decided by the       compiler/os)         Associate the name x with this memory location.          Store the value 3 in this location. The space allocated can be obtained with printf(“%d”,sizeof(x)); The value stored can be obtained with printf(“%d”,x); The memory location or address can be obtained with & printf(“%p”,&x); // &x   is the address of the variable x. The pointer variabl