⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 all.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta name="generator" content=  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">  <title>Standard C Memory</title>  <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table>  <tr>  <td>  <div class="body-content">  <div class="header-box">    <a href="../index.html">cppreference.com</a> &gt; <a href=    "index.html">Standard C Memory</a>  </div>  <div class="name-format">    calloc  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;stdlib.h&gt;  void* calloc( size_t num, size_t size );</pre>  <p>The calloc() function returns a pointer to space for an array of  <em>num</em> objects, each of size <em>size</em>. The newly allocated  memory is initialized to zero.</p>  <p>calloc() returns <strong>NULL</strong> if there is an error.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="free.html">free</a><br>    <a href="malloc.html">malloc</a><br>    <a href="realloc.html">realloc</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    free  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;stdlib.h&gt;  void free( void* ptr );</pre>  <p>The free() function deallocates the space pointed to by  <em>ptr</em>, freeing it up for future use. <em>ptr</em> must have  been used in a previous call to <a href="malloc.html">malloc</a>(),  <a href="calloc.html">calloc</a>(), or <a href=  "realloc.html">realloc</a>(). An example:</p>  <pre class="example-code">   typedef struct data_type {     int age;     char name[20];   } data;                 data *willy;   willy = (data*) malloc( sizeof(*willy) );   ...   free( willy );               </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="calloc.html">calloc</a><br>    (C/C++ Keywords) <a href="../keywords/delete.html">delete</a><br>    <a href="malloc.html">malloc</a><br>    (C/C++ Keywords) <a href="../keywords/new.html">new</a><br>    <a href="realloc.html">realloc</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    malloc  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;stdlib.h&gt;  void *malloc( size_t size );</pre>  <p>The function malloc() returns a pointer to a chunk of memory of  size <em>size</em>, or <strong>NULL</strong> if there is an error.  The memory pointed to will be on the heap, not the stack, so make  sure to free it when you are done with it. An example:</p>  <pre class="example-code">   typedef struct data_type {     int age;     char name[20];   } data;                 data *bob;   bob = (data*) malloc( sizeof(data) );   if( bob != <strong>NULL</strong> ) {     bob-&gt;age = 22;     strcpy( bob-&gt;name, &quot;Robert&quot; );     printf( &quot;%s is %d years old\n&quot;, bob-&gt;name, bob-&gt;age );   }   free( bob );         </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="calloc.html">calloc</a><br>    (C/C++ Keywords) <a href="../keywords/delete.html">delete</a><br>    <a href="free.html">free</a><br>    (C/C++ Keywords) <a href="../keywords/new.html">new</a><br>    <a href="realloc.html">realloc</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    realloc  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;stdlib.h&gt;  void *realloc( void *ptr, size_t size );</pre>  <p>The realloc() function changes the size of the object pointed to  by ptr to the given size. size can be any size, larger or smaller  than the original. The return value is a pointer to the new space, or  <strong>NULL</strong> if there is an error.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="calloc.html">calloc</a><br>    <a href="free.html">free</a><br>    <a href="malloc.html">malloc</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -