I'm making a Camera struct. the struct use a vec3
which is defined with typedef float vec3[3]
.
To initialize a vec3
I do vec3 vector = {0.,0.,0.};
My Cameras
struct is like this:
typedef struct Cameras {
vec3 eye;
vec3 target
} Camera;
but when I do:
Camera cam;
cam.eye = { .5, 1., 0. };
it crashes and the compiler tells me: expression must be modifiable
.
I thought it was an error with pointer but no, and replacing vec3 eye
to vec3 * eye
and cam->eye = {.5,1.,0.}
changes nothing.
Am I creating the struct the wrong way or is a really common issue C and I'm just blind?
here my goal is not only to initalise the array, but also accessing the data and modifing/passing into function after the creation.