I am very new to C. coming from Python, Java and C# worlds. This might be a stupid question but I am getting segmentation fault:
// struct for storing matrices
t
You need to allocate memory for A.elts
to point to. You can do this with malloc
. What you are doing is coping the constant array you specified into whatever address elts
happens to point to (it is uninitialized).
You can also point A.elts
to the constant array like so:
float *myFloats = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
A.elts = myFloats;