?? test12_2.txt
字號(hào):
#include "headfile.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <netdb.h>
int main(int argc,char **argv)
{
char ptr,*pptr;
char str[INET6_ADDRSTRLEN];
struct hostent *hptr;
while(--argc>0)
{
ptr=*(++argv);
if(hptr=gethostbyname(ptr)==NULL)
{
err_msg("gethostbyname call error:%s,%s\n",ptr,hstrerror(h_error));
continue;
}
printf("canonical name:%s\n",hptr->h_name);
for(pptr=hptr->h_aliases;*pptr!=NULL;pptr++)
printf("the aliases name is:%s\n",*pptr);
switch(hptr->h_addrtype)
{
case AF_INET:
case AF_INET6:
pptr=hptr->h_addr_list;
for(;*pptr!=NULL;pptr++)
printf("address:%s\n",inet_ntop(hptr->h_addrtype,*pptr,str,sizeof(str)));
break;
default:
err_sys("unknown addrtype");
break;
}
}
exit(0);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -