Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ Pointers and Memory Allocation Quandry

Name: Anonymous 2010-12-17 23:52

Hello /prog/, I have a minor problem with C++.

I'm trying to do this:

void* ReadData(float** array, int length){
*array = new float[length];
};

I call:

ReadData(&my_array, 1234);

..but when I try to read the values I get junk.

printf("%f\n", my_array[0]);

I've tried allocating the memory before passing the pointer to the function but it just doesn't care and kills whatever data I was working with.

I've tried pretty much every trick I know aside from a global variable or taking my code out of a function entirely.

Halp?

Name: Anonymous 2010-12-18 1:11

>>12
test[0] actually comes up with accurate data... but the rest is junk just like before.
That's strange.
Are you sure that the problem is ReadFloatArray and not something else?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List