Inexplicable behavior of file_write()

Posted By: Bernardo

Inexplicable behavior of file_write() - 08/12/19 11:59

Hello, I'm desperate for banal storage.
Here is my code:

float N[12][60][12];
int filelength=60*12*12*4;
file_write("N.dat", N, filelength);

Seems to be right. But the file has only a size of 34 KB.

Does anyone have any idea what I'm doing wrong? Saving other files works!
Many thanks for your help

Forget it! Oh, dear, I got it!
Posted By: laz

Re: Inexplicable behavior of file_write() - 08/12/19 18:42

please post the solution for other people with the same or similar problems wink
Posted By: AndrewAMD

Re: Inexplicable behavior of file_write() - 08/12/19 19:08

For those wondering what the solution is, there was no problem. 60*12*12*4 = 34560, hence the 34 KB file.

But for aesthetic purposes, I would suggest writing it this way: sizeof(float)*12*60*12. This reads from left to right on the array declaration.
© 2024 lite-C Forums