阅读:2451回复:1
请高手帮我看看文件读写的错误!
我写了下面一个函数:
FILE * SaveResult(struct Result result) { FILE *fp; int i; /*-------create file to save result-------------*/ if((fp = fopen("/tffs0/test_result","a+"))==NULL) { printf("cannot open file test_result.\n"); return NULL; } printf("fp = %x\n",fp); if(fwrite(&Result,sizeof(Result),1,fp) != 1) printf("file write error!\n"); fclose(fp); return fp; } shell输出: -> SaveResult fp = 3fffffa0 0x3bec7260 (tShell): disk cache error: device 3bd7c850 block 243 errno c0006, disk removed while writing data, possible data loss 0x3bec7260 (tShell): disk cache error: device 3bd7c850 block 258 errno c0006, disk removed while writing data, possible data loss value = 1073741728 = 0x3fffffa0 上面printf("fp = %x\n",fp)是我测试文件指针是否有效,按输出看fopen应该是对的阿,那么问题出在下面的fwrite吗? |
|
|
沙发#
发布于:2009-11-25 11:52
有可能是tffs的配置问题,详情不明,你初始化文件系统了吗?设备是否挂接正常?
|
|