Sunday, March 17, 2013

Pointer Triple Dereferencing

#include<iostream>
using namespace std;
int main()
{
    int num=2;
    int *ptr=&num,**ptr1=&ptr,***ptr2=&ptr1;
    cout<<"num: "<<num;
    cout<<"\n&num: "<<&num;
    cout<<"\nptr: "<<ptr;
    cout<<"\n&ptr: "<<&ptr;
    cout<<"\n*ptr: "<<*ptr;
    cout<<"\n*ptr1: "<<*ptr1;
    cout<<"\nptr1: "<<ptr1;
    cout<<"\n**ptr1: "<<**ptr1;
    cout<<"\nptr2: "<<ptr2;
    cout<<"\n*ptr2: "<<*ptr2;
    cout<<"\n**ptr: "<<**ptr2;
    cout<<"\n***ptr2: "<<***ptr2;
    return 0;
}

0 comments:

Post a Comment