gpt4 book ai didi

c - & 和 * 运算符使我的 fread() 在 C 中成功

转载 作者:太空宇宙 更新时间:2023-11-04 06:51:35 26 4
gpt4 key购买 nike

好的,所以当我使用这段代码时

fread(&(*list) -> books, sizeof(struct NOVEL), 1, fpread);

一切正常。

但是,当我使用这个

fread (list -> books, sizeof(struct NOVEL), 1, fpread);

我收到此错误:成员引用基类型“LISTNODEPTR”(又名“struct listnode *”)不是结构或 union 。

我认为 * 和 & 相互抵消,那么为什么会这样呢?提前致谢。

最佳答案

*list 

是一个结构指针,

list 

是指向结构指针的指针。

因此,要访问您需要的书籍字段:(*list) -> 书籍

你需要弄清楚你的优先级:http://en.cppreference.com/w/c/language/operator_precedence

&(*list) -> books 

相同
&((*list) -> books)

不一样

list -> books

关于c - & 和 * 运算符使我的 fread() 在 C 中成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50361133/

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