What is pointer???
Definition:
A pointer is a special kind of variable in C and C++ that holds the address of another variable.
C language use a lot of pointers...:
there are some reasons.....
- It is the only way to express some computations.
- It produces compact and efficient code.
- It provides a very powerful tool.
- Arrays,
- Structures,
- Functions.
#include"stdafx.h"
#include"iostream"
usingnamespacestd;
int main()
{ /* Use of pointors*/
/*pointers only saves Adresses*/
int n=10;
int *a; /* *a is pointer*/
a=&n;
cout<<"Adress of n in pointer a="<<a<<endl;
cout<<"Value at adress n="<<*a<<endl;
cout<<"Adress of pointer a="<<&a<<endl;
cout<<"Increment in value at a="<<*a+1<<endl;
cout<<"increment in adress="<<a++;
getch();
return 0;
}
Output of this program is>>>
Adress of n in pointer a=0012FF28Value at address n=10
Adress of pointer a=))12FF1C
Increment in value at a=11
Increment in address=0012FF28
Hope so you will enjoy it......
No comments:
Post a Comment