Sunday, August 29, 2010

How to use Pointer in c tutorial | Pointers in Cplusplus | pointer in c language

,
What is Pointer?

Pointer is very important in C and C++. It's  a variable which stores memory of user type and primary variable. It Hold the value of memory of a variable.

Why we use Pointer?
Some time we need to storing the address of variable for solving this problem we use pointer which capable to storing the memory address of a variable.

Guideline for using pointer
1. Define * When we use pointer
2. when we store address of pointers of pointer then we use **variable name

Example of Pointer

#include<iostream.h>

int main ()
{
int first,second;
int * ptr;
ptr = &first;
*ptr = 10;
ptr = &second;
*ptr = 20;
cout << "first is " << first << endl;
cout << "second is " << second << endl;
return 0;
}

Output:- First is =10
Second is =20

0 comments to “How to use Pointer in c tutorial | Pointers in Cplusplus | pointer in c language”

Post a Comment