当前位置:网站首页>[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 &边栏推荐
- Win11怎么关闭开机自启动软件
- Powerful, easy-to-use, professional editor / notebook software suitable for programmers / software developers, comprehensive evaluation and comprehensive recommendation
- Linux下安装Redis,并配置环境
- ORA-01950
- 上大学后明白了哪些坑人的事?
- Understand the structure in C language in one article
- 【无标题】
- 再回顾集合容器
- Realize pyramids through JS (asterisk pyramid, palindrome symmetric digital pyramid)
- Test self-study people must see: how to find test items in software testing?
猜你喜欢

开发那些事儿:EasyCVR集群设备管理页面功能展示优化

由浅入深学会白盒测试用例设计

Hls4ml reports an error the board_ part definition was not found for tul. com. tw:pynq-z2:part0:1.0.

How to use console Log print text?

Interview question 1

Detailed configuration of network security "Splunk" in national vocational college skills competition

Arduino Stepper库驱动28BYJ-48步进电机测试程序

关于元宇宙下一代入口——脑机接口的实现

渗透工具-TrustedSec 公司的渗透测试框架 (PTF)

fastDFS入门
随机推荐
【多线程】锁策略
February 15, 2022: sweeping robot. There is a floor sweeping robot in the room (represented by a grid). Each grid in the grid has two possibilities: empty and obstacles. The sweeping robot provides fo
Is Dao safe? Build finance encountered a malicious governance takeover and was looted!
振弦采集模塊測量振弦傳感器的流程步驟
Realize pyramids through JS (asterisk pyramid, palindrome symmetric digital pyramid)
Stack Overflow 2022 开发者调查:行业走向何方?
【let var const】
EasyCVR通过国标GB28181协议接入设备,出现设备自动拉流是什么原因?
Problems encountered in installing MySQL in docker Ubuntu container
Solve the problem of slow or failed vscode download
Leetcode 1380 lucky numbers in matrix [array] the leetcode path of heroding
Sum the amount
Procédure de mesure du capteur d'accord vibrant par le module d'acquisition d'accord vibrant
EURA欧瑞E1000系列变频器使用PID实现恒压供水功能的相关参数设置及接线
Detailed configuration of network security "Splunk" in national vocational college skills competition
一文读懂C语言中的结构体
漏洞复现-.Net-ueditor上传
How to add transactions in JDBC
使用 Kibana Timelion 进行时间序列分析
JVM memory model