gpt4 book ai didi

c - fseek 错误

转载 作者:行者123 更新时间:2023-11-30 14:25:36 33 4
gpt4 key购买 nike

使用以下代码,我尝试从文件中读取 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所怀疑的那样。

关于c - fseek 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10161184/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com