Creating 1-D array:---- int type
int n=getSize();
int *arr=( int * ) malloc ( sizeof ( int ) * n);
//Do Some Stuff :)
..............................
//reallocating the same array.... making the size change:-
m=getSize(); //Getting the new size
arr=(int *) realloc(arr,m); //You can assign it to any pointer to an integer variable
2-D array:-With Number of rows and number of columns unknown
int n= getRows();
int m=getColumns();
int **arr=NULL;
arr=(int **)malloc(sizeof(int *) * n);
for ( int i=0;i<n;i++){
arr[i]=(int *) malloc(sizeof(int) * m);
2-D With Number of Columns Unknown but number of rows known say 10:
This can give you variable number of columns
int *arr[10];
for(int i=0;i<10;i++){
m=getColumns();
arr[i]=(int *)malloc(sizeof(int) * m);
}
Try for number of rows Unknown urself :) An exercise :) Use pointer to an array.