🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Void Pointers
Also, if I might ask, why aren't you using a float* for the function in the first place (if the reason is tied to other areas of your program, it makes sense, but just wondering out of curiosity).
I use Mingw32 (GNU Win32 compiler).
I've found that the problem is that the array of floats is going out of scope in my code, before the function which takes a void pointer is called. But I can't seem to fix this. myFunction in reality takes a structure, one of the properties of this structure is a (void *).
------------------
LoungePig
OpenGUI
float myArray[2];
myArray[0] = 1.8f;
myArray[1] = 0.9f;
myFunction( (void *) myArray );
Then in myFunction I cast these back to a float array, and write the values to stdout, but I end up with stupid numbers that arent what I said in the first place:
void myFunction(void *param)
{
float *myArray = (float *) param;
cout << myArray[0] << " " << myArray[1] << endl;
}
Why is this happening?
Thanks
-Geoff