Why would you use a void pointer in this code?

Because char* when printed using cout << something will try to print a string (cout << "Hello, World" << endl; uses char * [pedantically, in this example, a const char *] to represent the "Hello, World").

Since you don’t want to print a string at address 10000 (it would MOST LIKELY crash), the code needs to do something to avoid the pointer being used as a string.

So by casting to void* you get the actual address printed, which is the default for pointer types in general, EXCEPT char *.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)