简体   繁体   English

读取二进制文件

[英]reading a binary file

Is it necessary to use reinterpret_cast< char*> when reading from a binary file. 从二进制文件读取时是否需要使用reinterpret_cast <char *>。 Since I found that a explicit typecast worked as well eg (char*), sizeof(int). 因为我发现显式类型转换也可以正常工作,例如(char *),sizeof(int)。

both reinterpret_cast and the C-style explicit cast do exactly the same thing in your context. reinterpret_cast和C风格的显式强制转换在您的上下文中都做完全相同的事情。 I prefer reinterpret_cast as it makes the nastiness more explicit when reading the code. 我更喜欢reinterpret_cast,因为这样可以使代码阅读时更加清晰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM