C++ pointer to a pointer

You can create a pointer to point to another pointer. When pointing to a normal variable,
you create a pointer with a single * sign in front of the pointer name. A pointer to a pointer will require two * signs. A pointer to a pointer is useful when creating data structures such as Tree, Graph, etc.

#include <iostream>
#include <conio.h>
using namespace std;

int main(){
   int *p,x;
   int **pp;
   p=&x;//p points to x variable
   pp=&p; //pp points to p pointer
   *p=10;//use p to assign value to x variable
   **pp=100;//use pp to assign value to x variable
   //output x value in different ways
   //give the same result
   //output address of x variable in different ways
   //give the same result
   return 0;

Posted by: samorn | post date: 01-26-2013 | Subject: C++ Programming Language

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.