protoent.c

来自「目前已经有很多介绍计算机网络的书籍」· C语言 代码 · 共 40 行

C
40
字号
/* protoent.c: *  * Example getprotoent(3) program : */#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include <netdb.h>intmain(int argc,char **argv) {    int x;    struct protoent *pp;    for (;;) {        errno = 0;        if ( !(pp = getprotoent()) )            break;        printf("%s:\n"            "\tProtocol: %d\n"            "\tAliases:  ",            pp->p_name,            pp->p_proto);        for ( x=0; pp->p_aliases[x] != NULL; ++x )            printf("%s ",pp->p_aliases[x]);        putchar('\n');    }    if ( errno != 0     &&   errno != ENOENT ) /* For RH-6.0 */        fprintf(stderr,            "%s: getprotoent(3) %d\n",            strerror(errno),errno);    return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?