2012年3月18日

摘要: 使用gethostname()得到主机名int gethostname(char *name, size_t len)这个函数,调用后,会将主机名保存在name里面。而len是name的大小。以下是例程,编译后只需要运行就知道自己的主机名字了。知道自己名字后,我再调用了一下gethostbyname()来得到主机的一些其他信息。#include <netdb.h>#include <sys/socket.h>int main(int argc, char **argv){ struct hostent *hptr; char **pptr; char hostname[ 阅读全文

posted @ 2012-03-18 23:40 无忧consume 阅读(291) 评论(0) 推荐(0) 编辑


Copyright © 2024 无忧consume
Powered by .NET 8.0 on Kubernetes