当前位置:网站首页>[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如何取消任务栏隐藏?Win11取消任务栏隐藏的方法
- Modsim basic use (Modbus simulator)
- 自定义插入页面标签以及实现类似通讯录的首字母搜索
- Win11暂停更新点不了怎么办?Win11暂停更新是灰色的如何解决?
- HLS4ML/vivado HLS 报错解决方案
- JS proxy
- How can a programmer grow rapidly
- Realize pyramids through JS (asterisk pyramid, palindrome symmetric digital pyramid)
- [research data] observation on the differences of health preservation concepts among people in 2022 - Download attached
- JVM memory model
猜你喜欢

Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results

Getting started with fastdfs

【多线程】锁策略

实例讲解将Graph Explorer搬上JupyterLab

JS 之 常用内置类的使用

STC 32位8051单片机开发实例教程 三 程序编译设置与下载

fastDFS入门

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

servlet知识点

【多线程】 实现单例模式 ( 饿汉、懒汉 ) 实现线程安全的单例模式 (双重效验锁)
随机推荐
关于元宇宙下一代入口——脑机接口的实现
Hls4ml reports an error the board_ part definition was not found for tul. com. tw:pynq-z2:part0:1.0.
一个悄然崛起的国产软件,低调又强大!
面试题篇一
通过js实现金字塔(星号金字塔,回文对称数字金字塔)
一文读懂C语言中的结构体
[untitled]
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
list大集合等比分割成多个小list集合
Time series analysis using kibana timelion
PowerDesigner design name and comment replacement
Linux下安装Redis,并配置环境
为定时器和延时器等其它情况的回调函数绑定当前作用域的this
Iframe 父子页面通信
今日群里分享的面试题
math_ Use differentiation to calculate approximate value
对金额进行求和
2022/5/23-2022/5/30
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
渗透工具-TrustedSec 公司的渗透测试框架 (PTF)