当前位置:网站首页>关于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
- IP packet header analysis and static routing
- upload (1-6)
- Zhubo Huangyu: these spot gold investment skills are not really bad
- Getting started with rce
- These 18 websites can make your page background cool
- Introduction to Chapter 8 proof problem of njupt "Xin'an numeral base"
- 2022年机修钳工(高级)考试题模拟考试题库模拟考试平台操作
- Comparison of several distributed databases
- 【华南理工大学】考研初试复试资料分享
猜你喜欢

IP packet header analysis and static routing

Recommendation number | what are interesting people looking at?

Xampp configuring multiple items

研究生可以不用学英语?只要考研英语或六级分数高!

Getting started with rce

国富氢能冲刺科创板:拟募资20亿 应收账款3.6亿超营收
![[cloud resources] what software is good for cloud resource security management? Why?](/img/c2/85d6b4a956afc99c2dc195a1ac3938.png)
[cloud resources] what software is good for cloud resource security management? Why?

瑞能实业IPO被终止:年营收4.47亿 曾拟募资3.76亿

【华南理工大学】考研初试复试资料分享

Kotlin collaboration uses coroutinecontext to implement the retry logic after a network request fails
随机推荐
2022 driller (drilling) examination question bank and simulation examination
Why do I support bat to dismantle "AI research institute"
[cloud resources] what software is good for cloud resource security management? Why?
Getting started with rce
tidb-dm报警DM_sync_process_exists_with_error排查
LeetCode_69(x 的平方根 )
判断变量是否为数组
UE源码阅读[1]---由问题入手UE中的延迟渲染
Convolutional Neural Networks简述
Fault analysis | analysis of an example of MySQL running out of host memory
How to divide a large 'tar' archive file into multiple files of a specific size
Introduction to Chapter 8 proof problem of njupt "Xin'an numeral base"
SSH免密码登录详解
Deep copy is hard
深拷贝真难
Attack and defense world crypto WP
Linked list (simple)
那些考研后才知道的事
国富氢能冲刺科创板:拟募资20亿 应收账款3.6亿超营收
Redis6 data type and operation summary