初级会员
- 积分
- 66
- 金钱
- 66
- 注册时间
- 2022-4-8
- 在线时间
- 81 小时
|
发表于 2023-1-31 00:08:28
|
显示全部楼层
为什么我的只能写入4个字符?以下是我的代码:
- //写入数据到文件
- void testWrite(char *filePath, char *writeBuffer)
- {
- FIL fnew; //文件对象
- FRESULT write_SD; //fatfs返回代码
- UINT fnum; //函数到时返回写入的字节数
- write_SD= f_open(&fnew,filePath, FA_OPEN_ALWAYS|FA_WRITE);
- write_SD= f_lseek(&fnew,f_size(&fnew));
- write_SD= f_write(&fnew, writeBuffer , sizeof(writeBuffer), &fnum);
- if(write_SD==FR_OK)
- printf("-testWrite: 写入成功!\r\n");
- else {
- printf("-testWrite: 写入失败!\r\n");
- }
- write_SD=f_close(&fnew);
- }
复制代码
testWrite("Test/testWrite.txt", "0123456789abcdef"); |
|