linux+字符转换+头文件,请教在linux C中怎样把ip字符串和整型数字之间的转换问题...

我知道在win下面,用inet_addr和inet_ntoa函数可以方便的进行相互转换,请问在linux有类似的函数吗?有的话需要什么头文件?

谢谢了

|

一样的。有这样的函数

在 #include 中

|

需要告诉楼主的是这两个函数是Unix里的函数,准确的说是最早是出现在4.2BSD里的。

INET(3)                FreeBSD Library Functions Manual                INET(3)

NAME

inet_aton, inet_addr, inet_network, inet_ntoa, inet_ntop, inet_pton,

inet_makeaddr, inet_lnaof, inet_netof -- Internet address manipulation

routines

LIBRARY

Standard C Library (libc, -lc)

SYNOPSIS

#include

#include

#include

#include

int

inet_aton(const char *cp, struct in_addr *pin);

in_addr_t

inet_addr(const char *cp);

in_addr_t

inet_network(const char *cp);

char *

inet_ntoa(struct in_addr in);

const char *

inet_ntop(int af, const void * restrict src, char * restrict dst,

socklen_t size);

int

inet_pton(int af, const char * restrict src, void * restrict dst);

struct in_addr

inet_makeaddr(in_addr_t net, in_addr_t lna);

in_addr_t

inet_lnaof(struct in_addr in);

in_addr_t

inet_netof(struct in_addr in);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值