Pointers
Computers memory is divided into memory locations. Size of basic location is 1 byte. Each location has a unique address. We know that for each variable a memory location will be assigned, that means for each variable there is a unique address. If “a” is a variable, we can find its address using operator “&” (address of operator) as follows:
&a
A pointer is a variable that can store address of another variable or in other words, a variable that can point to another variable is known as a pointer.
Pointer declaration:
int *p,*q;
float *r;
char *t;
double *s,*v;
Here, p and q are pointers to an integer, i.e. p and q can store addresses of integer variables.
r is a pointer to float, i.e. r can store address of float variable.
Consider the following declaration:
int *p,a;
p --> pointer to int
a --> int variable
Address of “a” can be assigned to “p” as follows:
p=&a;
This means that a and *p are same.
CACKLE comment system