Is there any way to take array size from user in c++?
<p>i want to know if there is a way to take size of a dimentional array from user?
for example for size of a matrix i have tried to definition a pointer,and after takeing size of matrix make memory.
this is:  `</p>

<pre><code>void getMatrixSize(&amp;int,&amp;int);  
void makeMatrix(int **mat,int,int);  
void getMatrixData(int **mat,int,int);  

int matrixRow,matrixColumn;  
int **A=NULL;  

int main()  
{  
   int row,column;  
   getMatrixSize(row,column);  
   makeMatrix(A,row,column);  
   getMatrixData(A,row,column);  
}  
getMatrixSize(int &amp;row,int &amp;column)  
{  
   cout&lt;&lt;"Enter matrix row:";  
   cin&gt;&gt;matrixRow;  
   row=matrixRow;  
   cout&lt;&lt;"Enter matrix column:";  
   cin&gt;&gt;matrixColumn;  
   column=matrixColumn;  
}  
makeMatrix(int**mat,int row,int column)  
{  
   int i=0;  
   mat=(int**)malloc(sizeof(int)*row);  
   if(mat==NULL)  
   {  
      cout&lt;&lt;"Error in getting memory";  
      exit(1);  
   }  
   for(i=0;i&lt;row;i++)  
   {  
      mat[i]=(int*)malloc(sizeof(int))*column);  
      if(mat[i]==NULL)  
      {   
         cout&lt;&lt;"Error in getting memory";  
         exit(1);  
      }  
   }  
}  
void makeMatrixData(int**mat,int row,int column)  
{  
   int i,j;  
   for(i=0;row&gt;i;i++)  
   {  
      for(j=0;column&gt;j;j++)  
      {  
         printf("m[%d][%d]=",i+1,j+1)  
         cin&gt;&gt;mat[i][j];  
      }  
   }  
}   
</code></pre>

<p>the program don't give any error but when i run it, it don't work. when i checked the debuge i realized that it take memory for mat not for A.<br>
this was my idea and didn't find anyway to make it work.do we have any way for take size of a dimentional array from user?</p>
