当前位置:网站首页>[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 &边栏推荐
- [research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
- C#联合halcon应用——大华相机采集类
- 【let var const】
- Remove line breaks from MySQL query results
- Iframe 父子页面通信
- Win11快捷键切换输入法无反应怎么办?快捷键切换输入法没有反应
- 由浅入深学会白盒测试用例设计
- Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
- [AI server setup] CUDA environment
- 一个程序员如何快速成长
猜你喜欢

Test self-study people must see: how to find test items in software testing?

The key to the success of digital transformation enterprises is to create value with data

GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速

安装sharp报错

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

开发那些事儿:EasyCVR平台添加播放地址鉴权功能

Win11怎么关闭开机自启动软件
![[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached](/img/50/926cc5bce83f8b195b3e2072b656bf.jpg)
[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached

墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
![[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached](/img/c8/a205ddc2835c87efa38808cf31f59e.jpg)
[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached
随机推荐
Unreal Engine packaging project
HLS4ML报错The board_part definition was not found for tul.com.tw:pynq-z2:part0:1.0.
再回顾集合容器
对金额进行求和
Win11怎么关闭开机自启动软件
Time series analysis using kibana timelion
EURA欧瑞E1000系列变频器使用PID实现恒压供水功能的相关参数设置及接线
使用Zadig从0到1搭建持续交付平台
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Arduino stepper library drive 28byj-48 stepper motor test program
How to use console Log print text?
JS ternary expression complex condition judgment
【多线程】 实现单例模式 ( 饿汉、懒汉 ) 实现线程安全的单例模式 (双重效验锁)
C # joint halcon Application - Dahua Camera Collection class
Battery simulation of gazebo robot
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Set object value changes null value object
强大、好用、适合程序员/软件开发者的专业编辑器/笔记软件综合评测和全面推荐
New window open page -window open
2022/6/8-2022/6/12