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:54

>>19
I feel sorry for you.

(Do you really need to use C++? Seriously, it's a fucking inconsistent madness, switch to something else.)

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