|
|
发表于 2005-6-25 20:27:07
|
显示全部楼层
程序我运行了,没有问题。是不是程序中没有包含必要的头文件?
- #include <netdb.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <sys/socket.h>
- int main(int argc,char *argv[])
- {
- struct hostent *hent;
- unsigned long lng=inet_addr(argv[1]);
- hent=gethostbyaddr((const char *)&lng,sizeof(unsigned long),AF_INET);
- printf("%s\n",hent->h_name);
- }
复制代码 |
|