Reputation: 449
I got a memcpy function that look strange on how it was used. I pasted it below. Can someone please help explain it. I do not know why the (void *). buffer is buffer in struct BLK. Thanks.
memcpy(
(void *) (BLK->buffer + left),
(void *) input,
fill
);
Upvotes: 0
Views: 121
Reputation: 10329
void *memcpy(void *dest, const void *src, size_t n);
may be the author wanted to be very sure that the compiler will not make errors doing its job :-)
In C, casting a object pointer from and to a void * is not needed. A pointer to a function is another thing.
Upvotes: 0
Reputation: 272447
There is no need for the cast, assuming input
and BLK->buffer
are already pointer types (which they really should be).
I can think of two reasons why they're there:
Upvotes: 1