C++控制台程序获取本机IP地址
来源:互联网 发布:java后端接口开发技术 编辑:程序博客网 时间:2024/06/03 15:26
#include <windows.h>
#include <winsock.h>
#include <string.h>
#include <iostream.h>
//using namespace std;
#pragma comment(lib,"wsock32.lib")
int main()
{
char buf[256]="";
struct hostent *ph = 0;
WSADATA w;
WSAStartup(0x0101, &w);
gethostname(buf, 256);
//String hostNmae = buf;//此处获得本机名称
ph = gethostbyname(buf);
const char *IP =inet_ntoa(*((struct in_addr *)ph->h_addr_list[0]));//此处获得本机IP
cout<<IP<<endl;//显示本机IP
WSACleanup();
return 0;
}
#include <winsock.h>
#include <string.h>
#include <iostream.h>
//using namespace std;
#pragma comment(lib,"wsock32.lib")
int main()
{
char buf[256]="";
struct hostent *ph = 0;
WSADATA w;
WSAStartup(0x0101, &w);
gethostname(buf, 256);
//String hostNmae = buf;//此处获得本机名称
ph = gethostbyname(buf);
const char *IP =inet_ntoa(*((struct in_addr *)ph->h_addr_list[0]));//此处获得本机IP
cout<<IP<<endl;//显示本机IP
WSACleanup();
return 0;
}
- C程序:获取本机IP地址
- C++控制台程序获取本机IP地址
- 获取本机IP地址程序
- C/C++获取本机IP地址
- C++/VC 获取本机IP地址
- C语言获取本机IP地址
- 获取本机IP地址 linux c
- C#------如何获取本机IP地址
- 用程序获取本机IP地址,mac地址
- C语言 获取本机IP地址,非回环地址
- c/c++ 获取本机的IP和Mac地址
- 获取本机IP地址
- 获取本机IP地址
- 获取本机IP地址
- 获取本机IP地址
- 获取本机IP地址
- 获取本机IP地址
- 获取本机IP地址
- HBase WAL原理学习
- 密钥管理
- tomcat部署服务配置备忘
- 命名空间和std用法
- vc2005编译出来的程序实现绿色版,即无须安装运行库
- C++控制台程序获取本机IP地址
- this & super
- C++查漏补缺读书笔记一 友元(friend)
- Qt系统托盘程序
- 【算法】康托展开
- ERROR: ORA-12560: TNS: 协议适配器错误--解决办法
- Genesis-3D 入门教程—23.动画融合
- 【cocos2d-x IOS游戏开发-捕鱼达人18】积分板实现
- sku算法[http://ued.taobao.org/blog/?p=5894]