Hi,
Im trying to migrate from programming in Matlab over to C. Im trying
to make a simple function to multiply one matrix by the other. I've
realised that C can't determine the size of a 2d array, so im
inputting the dimensions of those myself.
The problem is that the output array (C=A*B) has as many rows as A and
as many columns as B. I would think of initialising C with:
double C[A_rows][B_cols];
It looks like the compiler doesn't like this at all.
What is the best way to define C? could i use a structure data type
for A and B, or do the dimensions of C need to be defined using
pointers? Perhaps the malloc function comes in somewhere.
I would greatly appreciate any help.
Thanks
Adam
Im trying to migrate from programming in Matlab over to C. Im trying
to make a simple function to multiply one matrix by the other. I've
realised that C can't determine the size of a 2d array, so im
inputting the dimensions of those myself.
The problem is that the output array (C=A*B) has as many rows as A and
as many columns as B. I would think of initialising C with:
double C[A_rows][B_cols];
It looks like the compiler doesn't like this at all.
What is the best way to define C? could i use a structure data type
for A and B, or do the dimensions of C need to be defined using
pointers? Perhaps the malloc function comes in somewhere.
I would greatly appreciate any help.
Thanks
Adam
Comment