c++ malloc
时间: 2023-09-13 15:13:23 浏览: 101
在C语言中,malloc函数用于动态分配内存空间。它的返回值是一个void指针,指向分配的空间的起始地址。如果内存分配成功,malloc函数会返回一个指向分配空间的指针;如果内存不足,malloc函数会返回NULL。因此,在使用malloc函数分配内存后,应该始终检查返回值以确保内存分配成功。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *3* [malloc函数详解](https://blog.csdn.net/xw13106209/article/details/4962479)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *2* [C++详解:关于malloc()](https://blog.csdn.net/HaohaoCppDebuger/article/details/120155769)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文