我需要在文件中存储一个结构,然后读回它以返回它。 我会尝试像这样将它写入文件:
void lld_tpWriteCalibration(struct cal cal) {
FIL fdst; /* file objects */
UINT bw; /* File write count */
/* Create destination file on the drive 0 */
wf_open(&fdst, "0:calibration.txt", FA_CREATE_ALWAYS | FA_WRITE);
wf_write(&fdst, cal, sizeof(cal), &bw);
wf_close(&fdst);
}
那行得通吗? 我怎样才能读回它并从此函数返回它?
struct cal lld_tpReadCalibration(void) {
}
结构是:
struct cal {
float xm;
float ym;
float xn;
float yn;
};
感谢您的帮助。
最佳答案
关于c - 在 C 文件中存储和恢复结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12753659/