I have some code with const void*
as below:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main()
{
const int p = 10;
char s[] ="I am newbie";
const void *vp;
vp = &p;
*(int*)vp = 11;
printf("%i\n", *(int*)vp);
vp= s;
printf("%s\n", (char*)vp);
return 0;
}
My question is why const void* vp
still be updated?
As my understanding, const variable can not be updated directly, is that correct for all types?