<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="C dynamic memory allocation - Page 20 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=C_dynamic_memory_allocation&amp;p=19">1.Previous</a><br />
<a accesskey="3" href="page.php?w=C_dynamic_memory_allocation&amp;p=21">3.Next</a>
</p>
<p>and the cast will have to be updated as well.</p>

<p>In C++, if <code>std::malloc</code> must be used, it is preferable to <code>static_cast</code> it, rather than use a raw cast:<syntaxhighlight lang="cpp">int* p = static_cast<int*>(malloc(10 * sizeof(*ptr)));</int*></syntaxhighlight></p>

<p><big>Common errors</big></p>
<p>The improper use of dynamic memory allocation can frequently be a source of bugs. These can include security bugs or program crashes, most often due to <a href="page.php?w=segmentation_fault">segmentation fault</a>s.</p>

<p>Most</p><p>
<a accesskey="1" href="page.php?w=C_dynamic_memory_allocation&amp;p=19">1.Previous</a><br />
<a accesskey="3" href="page.php?w=C_dynamic_memory_allocation&amp;p=21">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
