Java 字节缓冲区到 C
从 Windows 上的 C 程序中,我们需要像 Java 字节缓冲区一样读取和写入,该字节缓冲区在 BIG_ENDIAN 中存储二进制文件。
算法描述如下: http://mindprod.com/jgloss/binaryformats.html
需要读写 int 和漂浮。
有谁有执行此操作的示例 c 或 C++ 代码或参考吗?
TIA, 伯特
From a C program on Windows we need to read and write like a Java bytebuffer which stores binary in BIG_ENDIAN
The algorithm is described at :
http://mindprod.com/jgloss/binaryformats.html
Need to read and write int and float.
Does anyone have example c or C++ code that does this or a reference ?
TIA,
Bert
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为困难在于大端和小端之间的转换。
本文应该可以帮助您解决 Endian 转换问题。 它包含用于交换整数、长整数、浮点数和任意长度字节数组的字节顺序的代码。
http://www.codeproject.com/KB/cpp/endianness.aspx
交换任意类型的代码如下所示:
I assume the difficulty is in converting between Big Endian and Little Endian.
This article should help you out with the Endian conversions. It contains code to swap the byte order on integers, long integers, floating point numbers, and byte arrays of arbitrary length.
http://www.codeproject.com/KB/cpp/endianness.aspx
The code to swap an arbitrary type looks like this:
您想使用 htonl 和类似的。 其余的设计是你自己的。
You want to use htonl and similar. The rest of design is your own.