Thursday, 19 January 2012

Program Of Pointer In C


#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
int a,b,c;
int *ptr1,*ptr2,*ptr3;
a=10;
b=15;
c=45;
ptr1=&a;
ptr2=&b;
ptr3=&c;
printf("\n Value of a= %d",a);
printf("\n value of b= %d",b);
printf("\n value of c= %d",b);
printf("\n  Addrss of a= %u",ptr1);
printf("\n Address of b= %u",ptr2);
printf("\n Address of c= %u",ptr3);
getch();
}

--------------------------------------------------------------------------------------

Pointer is a variable that stores a memory address.

 OK, that is simple ! But, what is a memory address then?

 Every variable is located under unique location within a

 computer's memory and this unique location has its

 own unique address, the memory address. Normally,

 variables hold values such as 5 or “hello” and these 

values are stored under specific location within 

computer memory. However, pointer is a different beast,

 because it holds the memory address as its value and

 has an ability to “point” ( hence pointer ) to certain value 

within a memory, by use of its associated memory 

address.

No comments:

Post a Comment