IP地址整数 - ç [英] IP Address to Integer - C

查看:170
本文介绍了IP地址整数 - ç的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我previously张贴如何实现,将一个整数转换为IP地址的字符串的功能。因此,我们将如何去反之亦然,即给定一个字符串(154.111.23.23)这是一个地址,我们如何能够得到整数回来,不使用INET功能。

I previously posted how to implement a function that will convert an integer to an IP address string. So how would we go vice-versa, that is, given a string (154.111.23.23) that is an address, how can we get that integer back, using no inet functions.

推荐答案

scanf函数串入四个字节,并添加/它们转移到一个32位整数。

scanf the string into four bytes and add/shift them into a 32 bit integer.

这篇关于IP地址整数 - ç的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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