memcpy with destination pointer to const data

前端 未结 3 592
我在风中等你
我在风中等你 2021-01-13 04:41

I always thought that an statement like const int *a means a is an int pointer to const data and as such one should not b

3条回答
  •  误落风尘
    2021-01-13 05:26

    Casting to void* removes the association with an int - by throwing away the type, you throw away the type decorators, such as const

    Edit

    As from discussion below, I want to make clear, that the important part is not to what you cast (void* in the OQ), but the fact that you cast - this implies throwing away your original type and its decorators.

提交回复
热议问题