fbtgrant
驱动牛犊
驱动牛犊
  • 注册日期2009-11-24
  • 最后登录2010-01-09
  • 粉丝0
  • 关注0
  • 积分11分
  • 威望61点
  • 贡献值1点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2398回复:1

请高手帮我看看文件读写的错误!

楼主#
更多 发布于:2009-11-24 23:21
我写了下面一个函数:
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吗?
vxWorkser
hwybird
论坛版主
论坛版主
  • 注册日期2006-11-11
  • 最后登录2010-08-31
  • 粉丝0
  • 关注0
  • 积分988分
  • 威望359点
  • 贡献值0点
  • 好评度96点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2009-11-25 11:52
有可能是tffs的配置问题,详情不明,你初始化文件系统了吗?设备是否挂接正常?
游客

返回顶部