如何将标准IP地址格式字符串转换为十六进制和长整型? [英] How to convert standard IP address format string to hex and long?

查看:204
本文介绍了如何将标准IP地址格式字符串转换为十六进制和长整型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何从标准IP地址格式字符串(xxx.xxx.xxx.xxx)得到十进制或十六进制IP地址?



I我试过使用inet_addr()函数,但没有得到正确的结果。

我在84.52.184.224上测试了它

函数返回3770168404这是不正确的(正确的结果是1412741344)。

谢谢!


< htonl,htons,ntohl,ntohs函数可以用来在网络和本地字节顺序之间进行转换。

Does anyone know how to get the IP address in decimal or hex from standard IP address format string ("xxx.xxx.xxx.xxx")?

I've tried to use the inet_addr() function but didn't get the right result.

I tested it on "84.52.184.224"

the function returned 3770168404 which is not correct (the correct result is 1412741344).

Thanks!

解决方案

The htonl, htons, ntohl, ntohs functions can be used to convert between network and local byte orders.

这篇关于如何将标准IP地址格式字符串转换为十六进制和长整型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆