#include "stdafx.h"
#include "stdio.h"
#include "winsock2.h"
#pragma comment(lib,"ws2_32.lib")
int main(int argc, char* argv[])
{
if(argc!=1)
{
printf("Parameter error!\n");
printf("Usage:dns_console DomainName\n\n");
return 0;
}
WSADATA wsaData;
if(WSAStartup (MAKEWORD(2,2),&wsaData)!=0)
return 0;
char *pszIP,*pszName;
pszName=argv[1];
in_addr ip;
hostent* h=gethostbyname(pszName);
if(h->h_addr_list[0]!=NULL)
{
memcpy(&ip,h->h_addr_list [0],h->h_length);
pszIP=inet_ntoa(ip);
}
printf("域名解析器1.0\n%s的ip地址为%s\n",pszName,pszIP);
WSACleanup();
return 0;
}
#include "stdio.h"
#include "winsock2.h"
#pragma comment(lib,"ws2_32.lib")
int main(int argc, char* argv[])
{
if(argc!=1)
{
printf("Parameter error!\n");
printf("Usage:dns_console DomainName\n\n");
return 0;
}
WSADATA wsaData;
if(WSAStartup (MAKEWORD(2,2),&wsaData)!=0)
return 0;
char *pszIP,*pszName;
pszName=argv[1];
in_addr ip;
hostent* h=gethostbyname(pszName);
if(h->h_addr_list[0]!=NULL)
{
memcpy(&ip,h->h_addr_list [0],h->h_length);
pszIP=inet_ntoa(ip);
}
printf("域名解析器1.0\n%s的ip地址为%s\n",pszName,pszIP);
WSACleanup();
return 0;
}
我本将心向明月,奈何明月照沟渠,落花有意随流水,流水无心恋落花。