当前位置:网站首页>[C language] explain the usage of memset() function in detail
[C language] explain the usage of memset() function in detail
2022-07-01 19:58:00 【Embedded workplace】
1、memset Function introduction
void * __cdecl memset(void *_Dst,int _Val,size_t _Size);explain : Copy characters _Val( An unsigned character ) To parameter _Dst The front of the string to which it refers _Size Characters .memset The function is an initialization function , You can initialize a continuous memory to a certain value .
effect : Is to fill a given value in a memory block , It is the fastest way to clear a large structure or array .
The header file :#include <string.h>
Be careful :memset Functions are assigned by bytes .
2、 Program instance
Clear large structures or arrays
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Structure People
typedef struct {
int m;
int n;
int z;
}People;
int main(){
// Allocate memory space
People *peo = (People*)malloc(sizeof(People));
// Make a continuous memory initialize a specific value
memset(peo,0, sizeof(People));
printf("m = %d\n",peo->m);
printf("n = %d\n",peo->n);
printf("z &边栏推荐
- PowerDesigner design name and comment replacement
- HLS4ML进入方法
- List is divided into sets that meet and do not meet conditions (partitioningby)
- [research materials] national second-hand housing market monthly report January 2022 - Download attached
- fastDFS入门
- Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
- 安装sharp报错
- ORA-01950
- Object creation
- 2022/6/8-2022/6/12
猜你喜欢

uniapp使用腾讯地图选点 没有window监听回传用户的位置信息,怎么处理

Redis installation and startup in Windows environment (background startup)

JS的Proxy

漏洞复现-.Net-ueditor上传

Bind this of the current scope for callback functions in other cases such as timers and delayers

math_ Use differentiation to calculate approximate value

MYSLQ十种锁,一篇文章带你全解析

Example explanation: move graph explorer to jupyterlab

面试题篇一

再回顾集合容器
随机推荐
Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation
HLS4ML进入方法
[research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
解决VSCode下载慢或下载失败的问题
Problems encountered in installing MySQL in docker Ubuntu container
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
【蓝桥杯Web】2022年第十三届蓝桥杯Web大学组国赛真题解析
fastDFS入门
Solve the problem of slow or failed vscode download
Time series analysis using kibana timelion
JVM memory model
Using win7 vulnerability to crack the system login password
[Blue Bridge Cup web] analysis of the real topic of the 13th Blue Bridge Cup web university group match in 2022
[research materials] national second-hand housing market monthly report January 2022 - Download attached
集合对象值改变NULL值对象
Interview questions shared in today's group
今日群里分享的面试题
MYSLQ十种锁,一篇文章带你全解析
js三元表达式复杂条件判断