Here\'s my code:
#include
using namespace std;
int main()
{
void *x;
int arr[10];
x = arr;
*x = 23; //This is where I get the error
As the compiler message says, void*
is not a pointer to object type. What this means is that you cannot do anything with void*
, besides explicitly converting it back to another pointer type. A void*
represents an address, but it doesn’t specify the type of things it points to, and at a consequence you cannot operate on it.