linux 下如何让c程序 返回本机系统名字呢
c语言吧
全部回复
仅看楼主
level 5
子_愚 楼主
小弟的是C程序和linux 菜鸟 希望大哥 大姐们帮帮我把 小弟叩谢了!! T_T
2008年07月25日 02点07分 1
level 8
..你都知道你用的是LINUX了..还要这么干什么??不过返回CPU信息我知道...
2008年07月25日 04点07分 2
level 5
子_愚 楼主
对不起哈 是计算机机的名字! 类似#include
#include
int main(void){char a;DWORD MaxComputerNameLength = MAX_COMPUTERNAME_LENGTH + 1;char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];GetComputerNameA(ComputerName, &MaxComputerNameLength);puts(ComputerName);scanf("%c",&a);return 0;}这样的程序
2008年07月25日 04点07分 3
level 8
8pm
用 uname system call#include
int uname(struct utsname *buf);具体的看 man 2 uname不过,调用命令 hostname 或者 uname -n 更方便
2008年07月25日 06点07分 4
level 5
子_愚 楼主
谢谢 了解!
2008年07月25日 07点07分 5
1