如何将uint32_t转换为struct in_addr?
发布时间:2020-12-14 01:44:08 所属栏目:Windows 来源:网络整理
导读:#include stdio.h#include sys/socket.h#include netinet/in.h#include arpa/inet.hint main(){uint32_t ip = 0;printf("%sn",inet_ntoa(*(struct in_addr *)ip));return 0;} 我不想通过声明任何临时变量来做到这一点.该程序给出了分段错误. struct in_addr
#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main() { uint32_t ip = 0; printf("%sn",inet_ntoa(*(struct in_addr *)ip)); return 0; } 我不想通过声明任何临时变量来做到这一点.该程序给出了分段错误. struct in_addr { uint32_t s_addr; };
你正在将int转换为指针.也许你想要这个:
*(struct in_addr *)&ip 但结果是实现定义的(一开始就有字节序注意事项). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-7 – 为什么我的项目图标在Windows 7中看起来如此可
- 在Windows批处理文件中,您可以链式执行*不是*另一个批处理文
- windows-server-2012 – 打开Windows Server 2012 / Window
- windows-server-2012 – 对共享文件夹的NetworkService帐户
- 如何在Windows上使用PyPy?
- windows-server-2003 – 如何连接到特定的域控制器?
- Unity---在Hierarchy视图中将选中的对象的层级目录复制到剪
- windows-phone-7 – Windows Phone 7上诺基亚蓝的十六进制代
- wix – 一个MSI中的两个PathEdit对话框(错误2343 – 指定的
- windows – 批量从文件名中删除括号
推荐文章
站长推荐
- Capslock+ 键盘党都爱的高效利器 - 让 Windows 快
- 执行DOS命令并返回结果
- azure-storage-emulator – windows azure存储模
- Windows Server 2008 R2(x64) IIS7+PHP5.6.30(F
- osx – 可以在Windows机器上运行VMWare Fusion映
- Atitit webdav 的问题 -------------大文件传输问
- 如何在Windows 10中安装.NET 4 Framework
- 使用带Stretch的图像控制= UniformToFill – WP7
- windows – 在没有Assembly Manifest的情况下在G
- 更改Windows中的块日志(NTFS)
热点阅读