繁体   English   中英

与fseek的错误

[英]error with fseek

使用以下代码,我尝试从文件中读取4个字节:

FILE *f

uint32_t read_program(int A)
{
    long i;
    uint32_t strofprog;
    uint8_t tmp;
    i = 4*A;
    fseek(f,i,0);// set a position in file
    if((tmp = getc(f)) != EOF)
    {
        while((i%(4*A)) < 4)
        {
            fseek(f, i, SEEK_SET);
            tmp = getc(f);
            strofprog = tmp;
            strofprog <<= 8;
            i++;
        }
        return strofprog;
    }
    else
    { 
        fclose(f);
        return -1; 
    };
}

但是,当我运行它时,会导致以下错误:

main.c: In function ‘read_program’:
main.c:77: error: incompatible type for argument 1 of ‘fseek’
/usr/include/stdio.h:722: note: expected ‘struct FILE *’ but argument is of type ‘FILE’

我做错了什么,我该如何解决?

粘贴中的第85行:

fseek(*f,i,0);// set a position in file

正如@unwind所怀疑的那样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM