dynamically allocates 2 dimensional array
Implement a function foo that dynamically allocates a 2 dimensional array of integers and returns it. The signature of the function is as under -
int **foo(int rows, int columns)
int **foo(int rows, int columns)
return type of functn shd be int**..
ReplyDeleteplz correct me if m wrong
@divya i am sorry it should be int**
ReplyDeleteint foo(int rows,int columns){
ReplyDeleteint **a;
a = (int **)malloc(rows*sizeof((int *));
for(int i = 0;i<rows;i++)
a[i] = (int *)malloc((columns)*(sizeof(int));
return a;
}