Initializing a 2D array dynamically allocated
I'm working with 2D arrays so that I can perform many calculations with them, just as matrices with numbers on them. Right now I change the dimensions of the matrices within the code, so I know what the dimensions are.
I created a dynamically allocated 2d array, but I can't figure out how to initialize it. For instance:
Code:
int ROW=2;
int COL=2;
int main()
{
float **mat1=(float **)malloc(ROW*COL*sizeof(float *));
mat1[ROW][COL]= { {5.3, 7.4},{1.1, 3.7} };
.
.
.
Trying to initialize the array this way, I get an error from the compiler, which says: "expected expression before "{" token ". I need to find a way to initialize the whole array with a single instruction, any help would greatly be appreciated.
Thanks in advance!