#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdio.h>
#include<string.h>
#include<netdb.h>
#include<sys/utsname.h> //其实最主要就是它了
#include<sys/ioctl.h>
#include<fcntl.h>
#include<unistd.h>
#include <linux/if.h>
#include <linux/if_ether.h>
int main(int argc ,char **argv)
{
struct utsname hostname;
if(uname(&hostname)<0)
{
return ;
}
printf("OS %s\n",hostname.sysname); //操作系统名称
printf("node %s\n",hostname.nodename); //本机名称
printf("OS release %s\n",hostname.release); //操作系统内部版本号
printf("OS version %s\n",hostname.version); //操作系统发行版本号
printf("OS machine %s\n",hostname.machine); //硬件版本
return 0;
}
getosinfo之 uname()
最新推荐文章于 2022-01-13 22:10:52 发布