gethostbyname不能返回IP地址
为什么如下这段代码不能成功得到IP地址,打印出NULL了,环境为windows,dev c++ 和 VC 都失败了#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib,"WS2_32.lib")
int main(int argc, char *argv[]) {
struct hostent * remotehost;
remotehost = gethostbyname("www.baidu.com");
if (NULL == remotehost) printf("NULL\n");
return 0;
}