click on this link......

LinkGrand.com

Sunday 31 March 2013

pointers in C

     Pointers
    A pointer is a variable that stores the address of another variable.  Normally a variable stores a value, but a pointer stores the address of another variable.
    Each variable occupies some memory in the computer, which is given by its address. To find the address of the variable, use the "&" operator. 
e.g.
 int a = 10;
 printf("The value is %d ", a);
 printf("The address is %u", &a);

The address of a variable can then be stored in a pointer variable.  To declare a pointer variable to hold the address of an integer,

int *p;
p is a pointer to an integer.

To assign a value to this pointer variable
p = &a;

Now p contains the address of the integer variable a.

No comments:

Post a Comment