[英]typecasting in C
In my code I get this error : 在我的代码中,我得到此错误:
expected ‘const void *’ but argument is of type ‘struct in_addr’
I am using memcmp
can i type cast struct in_addr
to const void*
as const void * (struct in_addr )
我使用memcmp
我可以强制类型转换struct in_addr
到const void*
为const void * (struct in_addr )
You need to cast the address of your object, not the object itself: 您需要转换对象的地址 ,而不是对象本身:
(const void *)&my_obj
But in fact, such casts are implict, so you can just use: 但实际上,此类转换是隐式的,因此您可以使用:
&my_obj
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.