I need to use an array to store some data and save them to file.

But i normally not use all slots, sometimes maybe 3, 50 or 77, max 100...

How do i save the needed amount (3 in this example) of var values to file?
Code
function run() {
	
	string my_file = "Data\\FAA_TEST.csv";
	
        int  ar_used = 3;
	var my_array[100];	
	
	my_array[0] = 1000.0001;
	my_array[1] = 2000.0002;
	my_array[2] = 3000.0003;	
	
	file_delete(my_file);	
	file_write(my_file,my_array,ar_used*8);
		
	var my_read[100];
	
	file_read(my_file,my_read,10*8);
	
	int i;

	for(i=0;i<10;i++) printf("\nmy_array[%i] %f | my_read[%i] %f",i,my_array[i],i,my_read[i]);
	
	quit();
	
}
Is it correct this way or are there better ways?
Quote
my_array[0] 1000.000122 | my_read[0] 1000.000122
my_array[1] 2000.000244 | my_read[1] 2000.000244
my_array[2] 3000.000244 | my_read[2] 3000.000244
Later i want to read them, why does this 1000.0001>22< happen?

Thanks!

Last edited by laz; 08/12/19 21:30.