title: Dereferencing double pointer, triple pointers, and so on
body: <p>Below is a sample program I created to play around with pointers. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void addOne(int** ptr);
  void addTwo(int*** ptr);
  void addThree(int**** ptr);
  void addFour(int***** ptr);
  
  int main()
  {
      int* ptr = nullptr; 
      int x = 1; 
      ptr = &amp;x;
  
      cout &lt;&lt; "Original value of x: " &lt;&lt; *ptr &lt;&lt; endl;
  
      addOne(&amp;ptr);
  
      cin.get();
      return 0;
  }
  
  void addOne(int** ptr)
  {
      **ptr += 1;
      cout &lt;&lt; "After adding 1: " &lt;&lt; **ptr &lt;&lt; endl;
      addTwo(&amp;ptr);
  }
  
  void addTwo(int*** ptr)
  {
      ***ptr += 2;
      cout &lt;&lt; "After adding 2: " &lt;&lt; ***ptr &lt;&lt; endl;
      addThree(&amp;ptr);
  }
  
  void addThree(int**** ptr)
  {
      ****ptr += 3;
      cout &lt;&lt; "After adding 3: " &lt;&lt; ****ptr &lt;&lt; endl;
      addFour(&amp;ptr);
  }
  
  void addFour(int***** ptr)
  {
      *****ptr += 4; 
      cout &lt;&lt; "After adding 4: " &lt;&lt; *****ptr &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The program above will give me the following output:</p>
  
  <pre><code>Original value of x: 1
  After adding 1: 2
  After adding 2: 4
  After adding 3: 7
  After adding 4: 11
  </code></pre>
  
  <p>Now focus on the addFour function:</p>
  
  <pre><code>void addFour(int***** ptr)
  {
      *****ptr += 4; 
      cout &lt;&lt; "After adding 4: " &lt;&lt; *****ptr &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Now what I did was I reduced the number of *s in the addFour function by doing this:</p>
  
  <pre><code>void addFour(int***** ptr)
  {
     ****ptr += 4; 
     cout &lt;&lt; "After adding 4: " &lt;&lt; ****ptr &lt;&lt; endl;
  }
  </code></pre>
  
  <p>When I did the above code, it gave me the following output:</p>
  
  <pre><code>Original value of x: 1
  After adding 1: 2
  After adding 2: 4
  After adding 3: 7
  After adding 4: 010EFDE0
  </code></pre>
  
  <p>My question then is, what is the following statements doing since I reduced the number of *s:</p>
  
  <pre><code>****ptr += 4; 
  cout &lt;&lt; "After adding 4: " &lt;&lt; ****ptr &lt;&lt; endl;
  </code></pre>
  
  <p>Can someone please explain this for me?</p>