Sunday, 20 May 2012

What are pointers? Distinguish between the address stored in the pointer and the value at that address.


A pointer is a derive data type in C. it is built from one of the fundamental data types available in C. Pointer contains memory address contains the instruction and data as a record.
Pointer is used to access and manipulate data stored in the memory. It is also known as referential variable.
All the variables defined in a program stored at specific memory location. If we want to get the address of the variable then we use “&” before the variable name. For example: int x=2;
The above declaration tells the C compiler to perform following actions:
1. Reserve space in the main memory to hold an integer value.
2. Associate the name x with this memory location.
3. Store the value 2 at this location.
       x location name
       2 value at the location
  6485 location address
To get the address of an integer variable, it has to be used with unary operator ‘&’ preceding the variable name. The memory address for the variable x holding the value 2 is 6485.

No comments:

Post a Comment