简体   繁体   中英

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 )

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM