There are certain tasks in C programming and other languages like PHP, what can only be done with pointers, like reading from a file requires a file pointer. Also to have a good understanding of pointers can give a great confidence to start improving the memory usage with decreasing the value duplication in programs.
A pointer is an address of a memory location where an actual value is stored. Every variables memory location can be accessed by using the ‘&’ am-percent. The asterisk’*’ is used to mark a variable as pointer. Pointers can point to pointer in any level, but in most cases there is not really a logical need to go more then pointer, to pointer depth. Pointer to pointer would be declared as ‘**’ and in that case to access the value at the pointer-pointer we have to use ‘*’ instead of ‘&’.
All pointers can only point to the same type, double pointer to a double variable, int pointer to int or int array.

   int myNum = 1;
   int *myNumPtr = &myNum; 

   printf("%d", &myNum);
   printf("%d", myNumPtr);//this also shows that printf takes a pointer not a value

C pointers can be declared as NULL if you don’t know what the memory location will be at the time but you know that you will have to use it later on.

   int myInt = 1;
   int *prtInt = NULL;
   if(!myInt)//if it is null if(myInt != NULL)
      ptrInt = &myInt;


Share This