C++ endian转换
生活随笔
收集整理的這篇文章主要介紹了
C++ endian转换
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
linux上可以使用endian.h,但是windows沒有。
解決方法是使用boost,可移植性強(qiáng)。
安裝
debian系列
sudo apt install -y libboost-dev使用
看文檔:https://www.boost.org/doc/libs/1_61_0/libs/endian/doc/conversion.html
示例
#include <iostream> #include <inttypes.h>#include <boost/endian/conversion.hpp>using namespace std;int main() {uint32_t x = 1;cout << x << endl;cout << boost::endian::native_to_big(x) << endl;return 0; } 1 16777216總結(jié)
以上是生活随笔為你收集整理的C++ endian转换的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PYTHON利用REMOVEBG库实现抠
- 下一篇: 1.1 VSCode中使用Code ru