asir
asir

Reputation: 13351

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 )

Upvotes: 1

Views: 2500

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272467

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

Upvotes: 7

Related Questions