memset对一维数组初始化
时间: 2023-08-25 16:05:18 浏览: 110
数组初始化.vi
对一维数组的初始化,可以使用memset函数。memset函数的定义如下:
```
void *memset(void *s, int c, size_t n);
```
其中,s是指向要初始化的数组的指针,c是要初始化的值,n是要初始化的字节数。
例如,对一个名为arr的一维数组进行初始化为0,可以使用以下代码:
```
int arr<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [C语言 用memset函数初始化](https://blog.csdn.net/Mmyine/article/details/114032101)[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^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [C++:用memset初始化数组](https://blog.csdn.net/dashumak/article/details/89517073)[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^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文