当前位置:网站首页>关于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
边栏推荐
猜你喜欢

-Web direction attack and defense world

What category does the Internet of things application technology major belong to

神经网络物联网未来发展趋势怎么样

Anchor navigation demo

昆仑太科冲刺科创板:年营收1.3亿拟募资5亿 电科太极持股40%

Kotlin collaboration uses coroutinecontext to implement the retry logic after a network request fails

那些考研后才知道的事

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

Detailed explanation of IP address and preparation of DOS basic commands and batch processing

Recommendation number | what are interesting people looking at?
随机推荐
Brief introduction to revolutionary neural networks
如何把大的‘tar‘存档文件分割成特定大小的多个文件
MySQL if else use case use
如何将 DevSecOps 引入企业?
锚点导航小demo
These 18 websites can make your page background cool
让秒杀狂欢更从容:大促背后的数据库(下篇)
SSH免密码登录详解
Financial one account Hong Kong listed: market value of 6.3 billion HK $Ye wangchun said to be Keeping true and true, long - term work
判断变量是否为数组
POI set the data format of the column (valid)
ETCD数据库源码分析——集群间网络层客户端peerRt
广发期货排名多少?网上办理广发期货开户安全可靠吗?
Liste des liens (simple)
js 从一个数组对象中取key 和value组成一个新的对象
Linked list (simple)
Laravel generate entity
研究生可以不用学英语?只要考研英语或六级分数高!
IP packet header analysis and static routing
VC开发非MFC程序内存泄漏跟踪代码