gpt4 book ai didi

c - 空指针取消引用

转载 作者:太空宇宙 更新时间:2023-11-04 00:31:27 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Dereferencing void pointers

我有这样一个函数调用:

void foo(void *context)   //function prototype
..
..
..
main()
{
.
.
foo(&(ptr->block)); //where ptr->block is of type integer.
.
.
.
void foo(void *context)
{
Here I try to use the ptr->block but am having problems. I have tried

if((int *)context ==1)
..
..
}

我在函数中将其类型转换回 int 以使用它。我在 foo() 函数中对它的取消引用有误吗?

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