C语言errorC2664:'fseek'

发布时间:2019-07-31 14:18:59

void read()//数据读入

{

    FILE *TS;

    if((TS=fopen("ts.txt","r"))==NULL)

    {

        printf("Can not open file\n");

        if((TS=fopen("ts.txt","w"))==NULL)

        printf("文件无法打开");

    }

    fseek(ts,0,SEEK_END);

    if(ftell(TS)>0)

    {

        rewind(TS);

        for(m=0;!feof(TS)&&fread(&ts[m],sizeof(struct tushu_xxsr),1,TS);m++);

    }

    printf("文件已导入");

    Sleep(2000);

    fclose(TS);

 }


F:\C++file\001.cpp(439) : error C2664: 'fseek' : cannot convert parameter 1 from 'struct tushu_xxsr [1000]' to 'struct _iobuf *'        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

推荐回答

你肯定是大小写搞错了

你的ts是struct tushu_xxsr [1000]而TS才是文件句柄,所以要改

   fseek(ts,0,SEEK_END);

   fseek(TS,0,SEEK_END);

建议,不要以这种方式定义变量名,容易出错

你可以用

tsfile来定义文件句柄,而用tsdata来定义数据

以上问题属网友观点,不代表本站立场,仅供参考!