1. #include "stdafx.h"
  2. #include <winsock2.h>
  3. #pragma comment (lib,"ws2_32.lib")
  4. int _tmain(int argc, _TCHAR* argv[])
  5. {
  6. p: printf("输入地址:");
  7. char szHost[256];
  8. memset(szHost,0,256);
  9. scanf("%s",szHost);
  10. unsigned long lAddr = inet_addr(szHost);
  11. if (lAddr == INADDR_NONE)
  12. {
  13. hostent *pHE = gethostbyname(szHost);
  14. if (!pHE)
  15. goto p;
  16. sockaddr_in sa;
  17. for (int iHost=0;pHE->h_addr_list[iHost];iHost++)
  18. {
  19. char *ip;
  20. unsigned int port;
  21. memcpy(&sa.sin_addr.s_addr, pHE->h_addr_list[iHost], pHE->h_length);
  22. ip = inet_ntoa(sa.sin_addr);printf("%s\n",ip);
  23. }
  24. }
  25. goto p;
  26. }

最新文章

  1. 2013 duilib入门简明教程 -- 部分bug 2 (14)
  2. &lt;&lt;&lt; request.getParameterMap()方法
  3. rxjava源码中的线程知识
  4. ASP.NET Web API 数据验证
  5. 设置zookeeper jvm内存
  6. Linux-Hostname-details
  7. 实用js+css多级树形展开效果导航菜单
  8. Web Developer可以做得更多
  9. eclipse 恢复被删除的文件
  10. Phonegap 3.0 拍照 出错的说明
  11. Swift - 使用HTML5进行iOS开发(将HTML5打包成iOS应用)
  12. 万方数据知识平台 TFHpple +Xpath解析
  13. angular : direative : scope | 指令scope里的符号@,=
  14. cpp命名空间
  15. EOJ3536 求蛇形矩阵每一行的和---找规律
  16. Java 8新特性探究(四)深入解析日期和时间-JSR310
  17. python--网络编程requests
  18. XUbuntu18.04(Bionic河狸)正式发布,系统安装升级记录
  19. vue双向绑定的时候把遍历的数组转为了字符串,并且再转回去数组进行绑定
  20. LeetCode 30 Substring with Concatenation of All Words(确定包含所有子串的起始下标)

热门文章

  1. 第1章jquery选择器
  2. J2ee项目 编译依赖顺序
  3. [python学习篇][系统学习][1]python标准库中文、英文网址(一些内建函数,标准库都可以在这里查找)
  4. [python篇][其他] python博客学习汇总
  5. HDU-2234 无题I
  6. 《常见问题集》Maven
  7. [POI2006] KRA-The Disks (贪心)
  8. ajax cache enable and ajax concurrency!
  9. Windows PowerShell Exit Codes
  10. LeetCode OJ——Minimum Depth of Binary Tree