I want to save some data(Integer data and float data) to SD card using MFS, but the example program (write(fd,buffer,strlen(buffer));) can only save string data, I want to know how to
using the write command to save a variable data in the form of decimal.
thank you!
Hi Botao,
It depends in which format you want to store these data.
If you want that data could be readable in different system (like PC). You should probably use string form. In this case for example sprinf() function.
sprintf(buffer, "Value of Pi = %f", pi_number);
write(fd,buffer,strlen(buffer));
If you want store numbers directly you can try using for example such case:
uint32_t usr_data[10];
len = write(flash_file, usr_data, sizeof(usr_data));
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------