当前位置:网站首页>关于memset赋值的探讨
关于memset赋值的探讨
2022-07-05 14:01:00 【蜡笔小金QAQ】
memset赋值
尽量用0x3f3f3f3f赋值,这样memset赋值结果和“=”赋值号效果相同,不会出现数字对不上。
0x7fffffff同理(7个f)
这是运行代码
可以看到对于memset,这四种方法是等效的。
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main()
{
memset(a, 0x3f, sizeof(a));
cout << a[0] << endl;
memset(a, 0x3f3f, sizeof(a));
cout << a[0] << endl;
memset(a, 0x3f3f3f, sizeof(a));
cout << a[0] << endl;
memset(a, 0x3f3f3f3f, sizeof(a));
cout << a[0] << endl;
cout << 0x3f << endl;
cout << 0x3f3f << endl;
cout << 0x3f3f3f << endl;
cout << 0x3f3f3f3f << endl;
return 0;
}
运行结果:
1061109567
1061109567
1061109567
1061109567
63
16191
4144959
1061109567
边栏推荐
- JS takes key and value from an array object to form a new object
- LeetCode_3(无重复字符的最长子串)
- 根据CronSequenceGenerator计算cron表达式的时间
- Rk3566 add LED
- 判断变量是否为数组
- 故障分析 | MySQL 耗尽主机内存一例分析
- Etcd database source code analysis -- rawnode simple package
- 2022 construction welder (special type of construction work) special operation certificate examination question bank and online simulation examination
- poi设置列的数据格式(有效)
- [machine learning notes] how to solve over fitting and under fitting
猜你喜欢

laravel-dompdf导出pdf,中文乱码问题解决

How to deal with the Yellow Icon during the installation of wampserver
![UE source code reading [1]--- starting with problems delayed rendering in UE](/img/fa/f33242b01e4da973fa36c2c6f23db6.png)
UE source code reading [1]--- starting with problems delayed rendering in UE

-Web direction attack and defense world

Scientific running robot pancakeswap clip robot latest detailed tutorial

Redis6 transaction and locking mechanism

Set up a website with a sense of ceremony, and post it to the public 2/2 through the intranet

嵌入式软件架构设计-消息交互

SAS接口有什么优势特点
![[South China University of technology] information sharing of postgraduate entrance examination and re examination](/img/a8/41e62a7a8d0a2e901e06c751c30291.jpg)
[South China University of technology] information sharing of postgraduate entrance examination and re examination
随机推荐
物联网应用技术专业是属于什么类
如何将 DevSecOps 引入企业?
uplad_ Labs first three levels
Convolutional Neural Networks简述
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
[South China University of technology] information sharing of postgraduate entrance examination and re examination
让秒杀狂欢更从容:大促背后的数据库(下篇)
判断变量是否为数组
基于 TiDB 场景式技术架构过程 - 理论篇
Hide Chinese name
TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
POI set the data format of the column (valid)
Google EventBus 使用详解
PHP basic syntax
Jetpack Compose入门到精通
研究生可以不用学英语?只要考研英语或六级分数高!
What is the future development trend of neural network Internet of things
js 从一个数组对象中取key 和value组成一个新的对象
2022 driller (drilling) examination question bank and simulation examination
Redis6 data type and operation summary