I'm trying to dynamically assign an array of structs in another struct,
typedef struct {
float azimuth;
float elevation;
float radius;
} SphericalCoords;
typedef struct {
SphericalCoords *sphericalCoords;
} Position;
typedef struct {
Position positionA;
Position positionB;
} UpdateVector;
then in the implementation
int postions= 3;
UpdateVector *uv;
uv = malloc(sizeof(UpdateVector));
SphericalCoords* coordsA ;
coordsA = (SphericalCoords*)realloc(coordsA,(positions * sizeof(SphericalCoords)));
SphericalCoords* coordsB;
coordsB = (SphericalCoords*)realloc(coordsB,(positions * sizeof(SphericalCoords)));
if(coordsA)
uv->positionA.sphericalCoords = coordsA;
if(coordsB)
uv->positionB.sphericalCoords = coordsB;
I'm trying to set coordsA
& coordsA
to each be an array of SphericalCoords (with length 3) - but they're never an array, just a single instance SphericalCoords
What am I doing wrong here?
EDIT - this question was wrong on my part, the array was being created but I could not see it in the debugger, and that was my misunderstanding that I would see it in the debugger... in code I could access the array and the contained structs and their properties [closing question without answering]