当前位置:网站首页>[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 &
边栏推荐
- Iframe 父子页面通信
- 3D全景模型展示可视化技术演示
- tensorflow报错Could not load dynamic library ‘libcudnn.so.8
- 漏洞复现-.Net-ueditor上传
- DS Transunet:用于医学图像分割的双Swin-Transformer U-Net
- The key to the success of digital transformation enterprises is to create value with data
- Servlet knowledge points
- math_ Use differentiation to calculate approximate value
- [research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached
- 2022/6/8-2022/6/12
猜你喜欢
Detailed configuration of network security "Splunk" in national vocational college skills competition
[research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
Hls4ml reports an error the board_ part definition was not found for tul. com. tw:pynq-z2:part0:1.0.
由浅入深学会白盒测试用例设计
AAAI2020: Real-time Scene Text Detection with Differentiable Binarization
Win11怎么关闭开机自启动软件
独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作
自定义插入页面标签以及实现类似通讯录的首字母搜索
EURA欧瑞E1000系列变频器使用PID实现恒压供水功能的相关参数设置及接线
fastDFS入门
随机推荐
JS 之 常用内置类的使用
Hls4ml/vivado HLS error reporting solution
DS transunet: Dual Swing transformer u-net for medical image segmentation
Win11快捷键切换输入法无反应怎么办?快捷键切换输入法没有反应
SQL 入门计划-1-选择
振弦采集模塊測量振弦傳感器的流程步驟
Understand the structure in C language in one article
Redis installation and startup in Windows environment (background startup)
由浅入深学会白盒测试用例设计
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
C # joint halcon Application - Dahua Camera Collection class
[research materials] national second-hand housing market monthly report January 2022 - Download attached
Related concepts of cookies and sessions
The key to the success of digital transformation enterprises is to create value with data
Use of common built-in classes of JS
C # joint Halcon application - Dahua camera acquisition class
JS proxy
Getting started with fastdfs
Mysql查询结果去除换行
[AI server setup] CUDA environment