大学生
最后登录1970-1-1
在线时间 小时
注册时间2018-6-4
|
f_write()返回数据 数量是 15
f_read()返回数据 数量是 19
但是 写入数据和读取数据时正确的
这是怎么回事啊!
UINT fs1num,fs2num; /* 文件成功读写数量 */
BYTE fs1ReadBuffer[1024]={0}; /* 读缓冲区 */
BYTE fs2ReadBuffer[1024]={0}; /* 读缓冲区 */
BYTE fs1WriteBuffer[] = "fs1 自定义数据"; /* 写缓冲区*/
BYTE fs2WriteBuffer[] = {"fs2 自定义数据"}; /* 写缓冲区*/
printf("\n****** New file three.txt ******\r\n");
strcpy(f_name,"three.txt");
res_fs1 = f_open(&fs1, "1:three.txt", FA_READ|FA_WRITE|FA_OPEN_ALWAYS);
if(res_fs1 == FR_OK)
{ printf(" %s 文件打开 Success ! \n",f_name);
res_fs1 = f_write(&fs1, fs1WriteBuffer, sizeof(fs1WriteBuffer), &fs1num);
if(res_fs1 == FR_OK)
{ printf(" %s 文件写入 Success ! \n",f_name);
printf("sizeof(fs1WriteBuffer) = %d 写入数据 %d 个 \n",sizeof(fs1WriteBuffer),fs1num); // fs1num = 15
printf(" 数据为-->%s \n", fs1WriteBuffer);
}
else
{ printf(" %s 文件写入 Fail ! \n",f_name);
}
f_close(&fs1);
printf(" %s 文件关闭 ! \n",f_name);
}
else
{ printf(" %s 文件打开 Fail !\n",f_name);
}
res_fs1 = f_open(&fs1, "1:three.txt", FA_READ|FA_WRITE|FA_OPEN_ALWAYS);
if(res_fs1 == FR_OK)
{ printf(" %s 文件打开 Success ! \n",f_name);
res_fs1 = f_read(&fs1, fs1ReadBuffer, sizeof(fs1ReadBuffer), &fs1num);
if(res_fs1 == FR_OK)
{ printf(" %s 文件读取 Success ! \n",f_name);
printf(" 读取数据 %d 个 \n",fs1num); // fs1num = 19
printf(" 数据为-->%s \n", fs1ReadBuffer);
}
else
{ printf(" %s 文件写入 Fail ! \n",f_name);
}
f_close(&fs1);
printf(" %s 文件关闭 ! \n",f_name);
}
else
{ printf(" %s 文件打开 Fail !\n",f_name);
}
|
|