c++ - 未初始化的数据和 memcpy

标签 c++ char

Mike Miller 在 240. Uninitialized values and undefined behavior 中说:

The wording in 3.9.1 [basic.fundamental] was carefully crafted to allow use of unsigned char to access uninitialized data so that memcpy and such could be written in C++ without undefined behavior

这是什么意思?为什么要访问未初始化的数据?

最佳答案

当您复制包含填充的struct 时,memcpy 也会复制填充。通常,填充是未初始化的。

关于c++ - 未初始化的数据和 memcpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13191277/

相关文章:

c++ - 为什么我的 Boost.Regex 搜索只报告一次匹配迭代?

c# - 无需安装的 C++ 数据库访问

C++ : The if statement not functioning correctly and proceeds to Invalid output

c - C 中 char* 的结尾

c++ - 从 std::string 中删除特定的连续字符重复

c++ - 编译错误 Undefined symbols for architecture x86_64 :

c++ - 如何写一个n元否定器?

java - 如何快速初始化char二维数组?

c - 请求int输入,如何防范char?

c# - 将 char 隐式转换为整数有什么好处?