Pointer in C


0  0 2016-10-12 01:54:13


A pointers is  special type of variable in C which holds address/ location of next variable. Pointers point to locations by keeping record of spot at which they were been stored. Pointers to variables been found by recording the address at which a variable stored. It is possible to find the address of  piece of storage in C using the special operator &.

For instance:consider  if location were a float type variable,then it would be easy to find a pointer to it called location_ptrs.

float location;

float *location_ptrs,*address;

location_ptrs = &(location);

or else

address = &(location);

Declarations of the pointers looks little strange at the first. The * symbol which stands in front of variable name is C languages way of declaring that particular variable to be pointer. The above lins make two identical pointers to floating point variable called as location, one of them is called as location_ptrs and the other called as address.The point is that pointer is just a place to keep the record of  address of  variable.

A pointer is bundle of information which contains two parts. One part is that the address of beginning of segment of the memory which holds whatever is pointed to. The another part is that the type of value that pointer points to beginning. This tells that computer how much of  memory after the beginning read and how that is interpret. Thus, if the pointer is of type int, the segment of memory returned will be of 4 bytes long (i.e. 32 bits) and be interpreted as integer. In the case of function, the type is type of value that function will return, although the address is address of the beginning of that function is executable.


include <stdio.h>

int main()


   int *ptr, q;

   q = 40;

   /* address of q is assigned to ptr */

   ptr = &q;

   /* display q's value using ptr variable */

   printf("%d", *ptr);

   return 0;


Comments (0)

Post Your Comments


Hong Kong Office

Find Us On

Website Development Company
Digital Marketing
website development company in Hong Kong
website designer in pune