当前位置:网站首页>Why can't memset initialize array elements to 1?
Why can't memset initialize array elements to 1?
2022-07-24 11:08:00 【practical_ sharp】
Today I found a very serious problem
memset Function cannot assign an array to 1
Looking up the data, I found ,memset The function is filled byte by byte , Complement in computer ,memset Functions can only be filled with all 0 Or all 1.
explain ,memset The function can only assign a full value to an array 0, Or all -1.
#include<string.h>
int main(){
int a[101];
memset(a,1,sizeof(a));
for(int i=1;i<=100;i++)
cout<<a[i]<<endl;
return 0;
}
The author found that the printed ones are not all 1, But not for 0 The positive integer (16843009)!

See blog for details :
https://www.cnblogs.com/blogofwu/p/4140563.html
边栏推荐
- 【Golang】golang实现urlencode urldecode函数
- 乘势而上,OceanBase推动数字支付精益增长
- Redis 100 million level data storage scheme hash slot partition
- Docker builds MySQL master-slave replication
- 2018 arXiv | Objective-Reinforced Generative Adversarial Networks (ORGAN) for Sequence Generation Mo
- Nodejs installation tutorial
- Docker installs 3 master and 3 slave redis clusters
- The difference between Lora wireless technology and lorawan gateway module
- Zero basic learning canoe panel (10) -- checkbox
- 1184. 公交站间的距离 : 简单模拟题
猜你喜欢

This should be postman, the most complete interface testing tool in the whole network

08【AIO编程】

Idea hidden Idea folder hides.Iml files

LoRa无线技术与LoRaWAN网关模块的区别

Siemens 200smart self created library and description

【C】 Understanding C language variable scope and life cycle from memory

1184. Distance between bus stops: simple simulation problem

Conversion between hexadecimal string and byte array

Fiddler抓包工具总结

STM32+ESP8266+MQTT协议连接阿里云物联网平台
随机推荐
【Golang】golang中time类型的before方法
Analysis of Lagrange multiplier method and its duality
Zero basic learning canoe panel (9) -- combobox
Zero basic learning canoe panel (10) -- checkbox
这个应该是全网最全的接口测试工具之postman
Reptiles and counter crawls: an endless battle
openresty lua-resty-logger-socket日志传输
Summary of const type data
轻松读懂三极管,原来它是这样工作的
数据可视化-《白蛇2:青蛇劫起》(1)
"Low power Bluetooth module" master-slave integrated Bluetooth sniffer - help smart door lock
Stm32+esp8266+mqtt protocol connects Alibaba cloud Internet of things platform
Artifact ffmpeg - operation video, extremely comfortable
Logic of automatic reasoning 06 -- predicate calculus
Only "a little bit", why do developers look up to you?
简单理解modbus功能码和分区
Collation of important MySQL configuration parameters
在线客服聊天系统源码_美观强大golang内核开发_二进制运行傻瓜式安装_附搭建教程
Build resume editor based on Nocode
【白帽子讲Web安全】第一章 我的安全世界观