首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >fseek出现错误

fseek出现错误
EN

Stack Overflow用户
提问于 2012-04-15 18:23:22
回答 1查看 515关注 0票数 0

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

代码语言:javascript
复制
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; 
    };
}

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

代码语言:javascript
复制
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’

我做错了什么,我如何才能纠正它?

EN

回答 1

Stack Overflow用户

发布于 2012-04-15 22:23:27

粘贴中的第85行:

代码语言:javascript
复制
fseek(*f,i,0);// set a position in file

正如@unwind所怀疑的那样。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10161184

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档