title: Why this program works else if parameters have passed through value?
body: <p>In this program I allocate a squared matrix in the function inserimento but I passed the arguments by value and so it wouldn't worked but the output of printf is right.
  Why?</p>
  
  <p>// MAX is a costant that represents the both maximum of lines and rows.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  
  #define MAX 10
  
  using namespace std;
  
  void insert(int **matrix,int &amp;riga);
  void print(int **matrix,int riga);
  
  
  int main(){
      int *matrix[MAX];
      int riga;
      insert(matrix,riga);
      print(matrix,riga);
  
      cin.get();
      return 0;
  }
  
  void insert(int **matrix,int &amp;riga){
      int i,j;
      cout&lt;&lt;"Dimmi la riga"&lt;&lt;endl;
      cin&gt;&gt;riga;
      while(cin.get()!='\n');
      cout&lt;&lt;"c";
      *matrix=new int [riga];
      cout&lt;&lt;"c";
      for(i=0;i&lt;riga;i++){
          matrix[i]=new int [riga];
      }
  
      for(i=0;i&lt;riga;i++){
          for(j=0;j&lt;riga;j++){
              cout&lt;&lt;"dimmi n"&lt;&lt;endl;
              cin&gt;&gt;matrix[i][j];
          }
      }
  }
  
  void print(int *matrix[],int riga){
      int i,j;
          for(i=0;i&lt;riga;i++){
              for(j=0;j&lt;riga;j++){
                  cout&lt;&lt;matrix[i][j]&lt;&lt;"\t";
              }   
              cout&lt;&lt;endl;
          }
  }
  </code></pre>