gpt4 book ai didi

c - 如何在 struct in_addr 中存储人类可读的 IP?

转载 作者:太空宇宙 更新时间:2023-11-04 07:04:07 25 4
gpt4 key购买 nike

假设您有以下 IP 地址:

192.168.0.255

如何将人类可读的 IP 地址存储到 struct in_addr 中?我对这种低级别的 C 网络编程是全新的,因此非常感谢任何帮助。

最佳答案

你可以做到

struct in_addr p;
inet_aton("192.168.0.255", &p.s_addr);

关于c - 如何在 struct in_addr 中存储人类可读的 IP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34736494/

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