unsigned char[] to const void* ?

How to convert these data types? i have an array of bytes in unsigned char[] array, and need to convert to const void* pointer.
1
2
3
4
const void* convert(unsigned char array[])
{
    return array;
}
Or it could be done easier, just discovered:

(const void*)myArray;
Last edited on
Consider not using C-style casts on pointers. Those are dangerous. Simple static_cast<const void*>(myArray) is safer and works as well.

But there is even simplier way to do that: myArray — all pointers can be implicitely cast to void type, so just use your pointer directly without any casts.
Topic archived. No new replies allowed.