Quote Originally Posted by Muthuveerappan View Post
My initial Doubt
-------------------
1) When the address of k1 can be stored in a int* variable, why can’t the address of the pointer p1 be stored in another int* variable ?
It could. The below program works just like yours:
Code:
#include <iostream>
using namespace std;

int main()
{
    int k1=20, *p1, *p2;

    p1 = &k1;
    p2 = (int*)&p1;

    cout << "k1  =" << k1  <<  "\t\t&k1 =" << &k1 << endl
         << "*p1 =" << *p1 <<  "\t\tp1  =" << p1  << "\t\t&p1 =" << &p1 << endl 
         << "**p2=" << **(int**)p2 << "\t\t*p2 =" << (int*)*p2 << "\t\tp2  =" << p2  << "\t\t&p2 =" << &p2 << endl;
}
However, why do you want to pretend that p2 is pointing to an integer while in fact p2 is pointing to an address. The compiler even warns you that your pointers are not correct, that's why I added the casts.

BTW, there is a concept of pointers that are not defining what they point to. They are defined as void *. The concept is used, when you have to store a memory address without knowing yet what exactly is at this memory, e.g. in network programming or inter-process communication.