Simple Pointer Example Program In C++


Definition

The pointer is a one of the C++ programming language data-type whose value refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.

Pointer Variable Assign Syntax: 

pointer_vaibale = &variable; 

C++ Example Pointer Program:

#include<iostream> 
#include<conio.h> 

using namespace std;

int main() {
    int i = 10;
    int *Ptr;

    Ptr = &i;
    cout << "\nValue Of i :" << i;
    cout << "\nAddress Of i :" << i;
    cout << "\nValue Of Ptr :" << Ptr;
    cout << "\nAddress Of Ptr :" << &Ptr;
    cout << "\nPtr's Pointer Value:" << *Ptr;
    cout << "\nPtr Equal to &i :" << *(&i);
}

Sample Output

Value Of i :10
Address Of i :10
Value Of Ptr :0x6dfefc
Address Of Ptr :0x6dfef8
Ptr's Pointer Value:10
Ptr Equal to &i :10

(Output may vary based on system and its memory)