memset 和 memset_s
时间: 2023-09-02 12:11:21 浏览: 297
memset和memset_s都是用来在一段内存中填充指定值的函数,但两者有一些区别。
memset函数的原型为void *memset(void *s, int ch, size_t n),它将s指向的内存块的前n个字节都设置为ch,并返回s。memset主要用于对较大的结构体或数组进行清零操作。例如,可以使用memset来清空一个数组,将数组中的所有元素都设置为0。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [memset和fill](https://blog.csdn.net/hy971216/article/details/80265938)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [memset和memset_s](https://blog.csdn.net/qq_41306849/article/details/112651646)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文