title: Am I using pointers to pointers right?
body: <p>I am a newbie in C++ programming and trying to learn the language from reading an Ebook called  <a href="http://www.cprogramming.com/c++book/" rel="nofollow" title="Jumping into C++">Jumping into C++ by Alex Allain</a>, and I have currently finished the dynamic memory allocation chapter and I must say that I find pointers difficult to understand. </p>
  
  <p>At the end of the chapter is a series of practice problem I can try out, I have completed the first problem (took me a while to get my code working) which is to <strong>write a function that builds the multiplication table of arbitrary dimensions</strong> (you have to use pointers for the problem), but I am not satisfied with my solution if it's correct and if I am using the pointers the right way, I want someone who has experience to point out the flaws, if there are, below is my own solution to the problem:</p>
  
  <pre><code>// pointerName.cpp : Defines the entry point for the console application.
  //
  
  #include "stdafx.h"
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  void multTable(int size){
  
      int ** x, result;
      x = new int*[size]; //  lets declare a pointer that will point to another pointer :).
      result = 0; 
  
      for(int h = 0; h &lt; size; h++){ // lets store the address of an array of integers.
              x[h] = new int [size];      
      }
      std::cout &lt;&lt; std::endl &lt;&lt; "*********************************" &lt;&lt; std::endl; // lets seperate. 
      for(int i=0; i &lt; size+1; i++){ // lets use the pointer like a two-dimensional array.
          for(int j=0; j &lt; size+1; j++){
              result = i*j; // lets multiply the variables initialized from the for loop.
              **x = result; // lets inialize the table.
              std::cout &lt;&lt; **x &lt;&lt; "\t"; // dereference it and print out the whole table.
          }
          std::cout  &lt;&lt; std::endl;
      }
      /************* DEALLOCATE THE MEMORY SPACE ************/
      for(int index = 0; index &lt; size; index++){
          delete [] x[index]; // free each row first.  
      }
      delete [] x; // free the pointer itself.
  }
  
  int main(int argc, char* argv[]){
  
      int num;
      std::cout &lt;&lt; "Please Enter a valid number: ";
      std::cin &gt;&gt; num; // Lets prompt the user for a number.
      multTable(num);
  
      return 0;
  }
  </code></pre>