C
Chris Haynes
Hello all,
I have a structure:
typedef struct UVstruct {
float u, v;
} uv;
Inside a function (A) i declare a pointer to an instance of this
structure:
UVstruct *pUV;
then from within the same function (A) i call another function (B)
that takes as one of its parameters the pointer declared above.
From within functionB i dynamically declare an array (pUVlocations is
the name of the passed pointer pUV within B):
pUVlocations = new UVstruct[number];
Still in B, I fill pUVlocations with some data. At the end of the
function pUVlocations contains all the data it should, and i do not
free pUVlocations.
However when the program has passed back to A, when I try to access
pUV it contains rubbish.
What am I doing wrong? Why does pUV not contain the data it was given
within B?
Many thanks,
Chris.
I have a structure:
typedef struct UVstruct {
float u, v;
} uv;
Inside a function (A) i declare a pointer to an instance of this
structure:
UVstruct *pUV;
then from within the same function (A) i call another function (B)
that takes as one of its parameters the pointer declared above.
From within functionB i dynamically declare an array (pUVlocations is
the name of the passed pointer pUV within B):
pUVlocations = new UVstruct[number];
Still in B, I fill pUVlocations with some data. At the end of the
function pUVlocations contains all the data it should, and i do not
free pUVlocations.
However when the program has passed back to A, when I try to access
pUV it contains rubbish.
What am I doing wrong? Why does pUV not contain the data it was given
within B?
Many thanks,
Chris.