How to print the value of const void*
<pre><code>#include &lt;iostream&gt;
using namespace std;

void fn(const void *l) {
    // How to print the value of l. The below line is giving error
    cout &lt;&lt; "***" &lt;&lt; *l;
}

int main() {
    cout &lt;&lt; "Hello World!";
    int d = 5;

    fn((char *) &amp;d);
    return 0;
}
</code></pre>

<p>Error:</p>

<p>In function 'void fn(const void*)':
Line 8: error: 'const void*' is not a pointer-to-object type
compilation terminated due to -Wfatal-errors.</p>

<p>Tried Casting as seen below. It didnt not help. Please provide suggestions.</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

void fn(const void *l) {
    // How to print the value of l. The below line is giving error
    int *pInt = static_cast&lt;char*&gt;(l);
    cout &lt;&lt; *pInt;
}

int main() {
    cout &lt;&lt; "Hello World!";
    int d = 5;

    fn((char *) &amp;d);
    return 0;
}
</code></pre>

<p>In function 'void fn(const void*)':
Line 9: error: static_cast from type 'const void*' to type 'char*' casts away constness
compilation terminated due to -Wfatal-errors</p>
