Introduction to pointer
Pointer is used to reference a memory location.
Pointer variable in C be used to store address of other variable.
Different properties of variable are:
A variable must have a name. It must follow rules of valid identifier in C.
2. Value of variable:
Variable should be assigned some value.
3. Memory location:
Each variable gets stored in a memory location that is represented as a hexadecimal number.
There are two pointer operators. They are:
i. Indirection Operator
Indirection operator is represented as * . It is used to declare a pointer variable or to refer to the value referenced by pointer variable.
Example: int *x;
ii. Address Operator
Address operator is represented as &. It is used to get a variable’s memory location .
NULL refers to pointer variable not having address stored in it.
We can determine the address of a variable with the help of address operator (&).
We can access value of a pointer variable using indirection operator.
y=&x; /* y contains the address of variable x*/
z=*y; /* *y contains the value of variable x whose address is contained in pointer variable y*/
Best Books of Computer Science