inet_ntoa()的问题
来源:互联网 发布:淘宝大股东是日本人 编辑:程序博客网 时间:2024/05/24 04:25
MSDN:The inet_ntoa function converts an (Ipv4) Internet network address into an ASCII string in Internet standard dotted-decimal format.
Syntax
C++
char* FAR inet_ntoa( _In_ struct in_addr in);
Parameters
- in [in]
An in_addr structure that represents an Internet host address.
Return value
If no error occurs, inet_ntoa returns a character pointer to a static buffercontaining the text address in standard ".'' notation. Otherwise, it returns NULL.
注意:返回的是静态指针。每次调用Inet_ntoa(),它就会覆盖上次调用时所使用的IP地址(内存被覆盖)。例如:
char *a1, *a2;
a1 = inet_ntoa(ina1.sin_addr); /* 这是198.92.129.1 */
a2 = inet_ntoa(ina2.sin_addr); /* 这是132.241.5.10 */
printf("address 1: %s\n",a1);
printf("address 2: %s\n",a2);
输出如下:
address 1: 132.241.5.10
address 2: 132.241.5.10
若要长久保存IP地址,还要事先定义一个内存区域,并将当前的静态区域内的IP地址拷贝到新定义的内存区域。
- inet_ntoa()的问题
- inet_ntoa 的问题
- inet_ntoa()多次调用时的问题
- inet_ntoa问题记录
- inet_ntoa只能转化IP地址 不能转域名的问题
- 关于VS2013下inet_ntoa函数不能使用的问题
- inet_ntoa的实现
- inet_ntoa的实现
- 有趣的inet_ntoa
- Java的inet_aton inet_ntoa
- inet_ntoa()的用法
- inet_ntoa()
- inet_ntoa()
- inet_ntoa()
- inet_ntoa()
- inet_ntoa
- inet_ntoa
- inet_ntoa的一个典型误用
- CodeIgniter 图像处理类 源代码分析
- 你觉得有哪些技能,经过较短的学习,就可以给你的生活带来巨大的帮助?
- Welcome to the Flying Circus
- gvim Gtk-WARNING **: Invalid input string错误的解决办法
- C/C++与JAVA的内存划分
- inet_ntoa()的问题
- 创意,有时候啥也不是
- cocos2d-x【小菜在学习】做个小游戏俄罗斯方块(三)
- hdoj 1205 吃水果
- 权限处理类PermissionServiceAdapter
- Variables
- C++类的虚函数详解
- Jquery实现的小案例3、小选项卡
- hdoj 1166 敌兵布阵