A pointer is the address of a variable (or the address of an array slot, the address of a struct member etc.). For as long as the pointed-to variable is alive, you can access its value by dereferencing the pointer.
You could say that a pointer variable holds addresses ... adresses for any kind of 'object' ... including the address of an other pointer variable ... and in that case, you then have a 'pointer to a pointer'.
One very common use of pointers is when you allocate dynamic memory ... The pointer then holds the address to the first byte in that newly allocated memory.
it takes value of a vairable or only takes adress of vairable ??
pointer variable takes address of another variable which must be same as pointer type.you can't point float variable using pointer to int declaration.you must have pointer to float in this case.look below :
ptr=&y; //Incorrect . Because ptr is pointer to int and it can't be used to point float.
ptr=&x //Correct. Because Both type are same.the statement will assign the address of x to pointer ptr
print *ptr //*ptr is de referencing(i.e. get the value at address)
*ptr=20 //set the value at address .Now x becomes 20
here is how you delcare a pointer
let 'a' be a variable
The statement below takes the adderess of the variable a
where as the syntax given below takes the value of the variable