gpt4 book ai didi

将数据转换回其原始项目

转载 作者:行者123 更新时间:2023-12-02 08:10:24 25 4
gpt4 key购买 nike

我有一些代码,但我不明白如何取回个别项目:

u32_t foo = ((u32_t)((d) & 0xff) << 24) | ((u32_t)((c) & 0xff) << 16) |  
((u32_t)((b) & 0xff) << 8) | (u32_t)((a) & 0xff)

我要输入这个转换的结果我希望将 IP 地址转换回其部分以显示。但是当我输入 192 168 1 200 时,我得到 0xC801A8C0 并且我没有将它转换回来。

有谁知道我如何在 union 结构中添加项目?我尝试使用 LwIP 但 union 结构有问题。我尝试访问 local_ip 和 remote_ip。 struct

最佳答案

u32_t d = (foo >> 24) & 0xFF; // Get the bits 32nd...25th
u32_t c = (foo >> 16) & 0xFF; // 24th...17th
u32_t b = (foo >> 8) & 0xFF; // 16th...9th
u32_t a = (foo) & 0xFF; // 8th...1st

这实际上与上面的代码相反。

关于将数据转换回其原始项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47731464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com