Sunday, September 19, 2010

Dynamically Allocation Multidimensional Arrays

Doing the ASS of my C programing language, I need to dynamically allocation two dimensional arrays.
 So the method is as below:
int **a; 
int i,m,n; 
scanf("%d %d",&m,&n); 
*a=(int **)malloc(m*sizepf(int *)); 
for (i=0;i<m;i++) 
       a[i]=(int *)malloc(n*sizeof(int)); 
//which is just like in C++: 
int m,n; 
int a[m][n]; 
cin>>m>>n;
very funny!

No comments:

Post a Comment