当前位置:网站首页>关于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
边栏推荐
- 神经网络物联网未来发展趋势怎么样
- MySQL if else use case use
- Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
- NFT value and white paper acquisition
- Login interface code
- tidb-dm报警DM_sync_process_exists_with_error排查
- 牛客网:拦截导弹
- 物联网应用技术专业是属于什么类
- 2022建筑焊工(建筑特殊工种)特种作业证考试题库及在线模拟考试
- Those things I didn't know until I took the postgraduate entrance examination
猜你喜欢
TiCDC 6.0原理之Sorter演进
[machine learning notes] several methods of splitting data into training sets and test sets
UE source code reading [1]--- starting with problems delayed rendering in UE
Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
SAS接口有什么优势特点
国富氢能冲刺科创板:拟募资20亿 应收账款3.6亿超营收
Assembly language - Beginner's introduction
昆仑太科冲刺科创板:年营收1.3亿拟募资5亿 电科太极持股40%
Scientific running robot pancakeswap clip robot latest detailed tutorial
深拷贝真难
随机推荐
TiFlash 面向编译器的自动向量化加速
【华南理工大学】考研初试复试资料分享
判断变量是否为数组
神经网络物联网未来现状和趋势及看法
uplad_ Labs first three levels
TiCDC 6.0原理之Sorter演进
锚点导航小demo
matlab学习2022.7.4
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
Simple PHP paging implementation
基于微信小程序的订餐系统
深拷贝真难
Google EventBus 使用详解
2022司钻(钻井)考试题库及模拟考试
Log4j utilization correlation
Require, require in PHP_ once、include、include_ Detailed explanation of the efficiency of repeated introduction of once class library
Liar report query collection network PHP source code
Elk enterprise log analysis system
3W原则[通俗易懂]
蓝桥杯学习2022.7.5(上午)