hostget.c
来自「Linux程序设计(原书第2版)源码」· C语言 代码 · 共 22 行
C
22 行
#include <sys/utsname.h>#include <unistd.h>#include <stdio.h>int main(){ char computer[256]; struct utsname uts; if(gethostname(computer, 255) != 0 || uname(&uts) < 0) { fprintf(stderr, "Could not get host information\n"); exit(1); } printf("Computer host name is %s\n", computer); printf("System is %s on %s hardware\n", uts.sysname, uts.machine); printf("Nodename is %s\n", uts.nodename); printf("Version is %s, %s\n", uts.release, uts.version); exit(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?