📄 prg7_1.c
字号:
// File: prg7_1.c
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
main(int argc, const char **argv)
{
ulong_t addr;
struct hostent *hp;
char **p;
if (argc != 2) {
(void) printf("usage: %s host_name\n", argv[0]);
exit (1);
}
hp = gethostbyname(argv[1]);
if (hp == NULL) {
(void) printf("host information for %s not found\n", argv[1]);
exit (2);
}
for (p = hp->h_addr_list; *p != 0; p++) {
struct in_addr in;
char **q;
(void) memcpy(&in.s_addr, *p, sizeof (in.s_addr));
(void) printf("%s\t%s", inet_ntoa(in), hp->h_name);
for (q = hp->h_aliases; *q != 0; q++)
(void) printf(" %s", *q);
(void) putchar('\n');
}
exit (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -