I tried to write my function like "memcpy" in C to copy a block of data from a source address to a destination address.
In line *dst_addr++ = *src_addr++;
, the error is appeared: "invalid use of void expression"
The function I wrote:
void MemCpy(void *src_addr, void *dst_addr, int length)
{
while(length--)
{
// copy by single byte
*dst_addr++ = *src_addr++;
}
return dst_addr;
}
I used void
to point to any object type if i need it later.
Why did I use the "void" wrong? Could someone explain my mistake?