当前位置:网站首页>关于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
边栏推荐
- Brief introduction to revolutionary neural networks
- Log4j utilization correlation
- Attack and defense world crypto WP
- 昆仑太科冲刺科创板:年营收1.3亿拟募资5亿 电科太极持股40%
- SAS接口有什么优势特点
- 2022年机修钳工(高级)考试题模拟考试题库模拟考试平台操作
- PHP basic syntax
- Linked list (simple)
- Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
- Google EventBus 使用详解
猜你喜欢

神经网络物联网未来现状和趋势及看法

TiCDC 6.0原理之Sorter演进

Zibll theme external chain redirection go page beautification tutorial

Comparison of several distributed databases

荐号 | 有趣的人都在看什么?

Detailed explanation of IP address and preparation of DOS basic commands and batch processing
![[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

OSI and tcp/ip protocol cluster
![[machine learning notes] several methods of splitting data into training sets and test sets](/img/f6/eca239bb4b1764a1495ccd9a868ec1.jpg)
[machine learning notes] several methods of splitting data into training sets and test sets

那些考研后才知道的事
随机推荐
VC开发非MFC程序内存泄漏跟踪代码
如何将 DevSecOps 引入企业?
研究生可以不用学英语?只要考研英语或六级分数高!
OSI and tcp/ip protocol cluster
故障分析 | MySQL 耗尽主机内存一例分析
[js] basic syntax - for loop
SAS接口有什么优势特点
web3.eth. Filter related
2022年机修钳工(高级)考试题模拟考试题库模拟考试平台操作
ELFK部署
2022 construction welder (special type of construction work) special operation certificate examination question bank and online simulation examination
ELK 企业级日志分析系统
明峰医疗冲刺科创板:年营收3.5亿元 拟募资6.24亿
Ordering system based on wechat applet
牛客网:拦截导弹
IP packet header analysis and static routing
判断变量是否为数组
::ffff:192.168.31.101 是一个什么地址?
Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
Linked list (simple)