0

使用以下代码,我尝试从文件中读取 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’

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

4

1 回答 1

2

粘贴中的第 85 行:

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

正如@unwind 所怀疑的那样。

于 2012-04-15T14:23:26.840 回答