I have a large multi-dimensional array: float largetable[32][256][128][3]
Is there a way to write this array to a binary file and read it back to the array easily in C++?
In VS2013 when I have the data array in a header file (which is not great form) but get a : fatal error C1060: compiler is out of heap space
So I figure reading it in and out is the way to go.
I'm a python programmer, so I'm relatively new to C++
use the fwrite() function to write the entire array in one shot:
FILE* pFile = fopen("filename", "wb");
fwrite(largetable, sizeof(largetable), 1, pFile);
fclose(pFile);
reading it back:
FILE* pFile = fopen("filename", "rb");
fread(largetable, sizeof(largetable), 1, pFile);
fclose(pFile);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With