|
帮忙看看这个程序,第十七行的错误该怎么改啊?
我改了半天也没改对.
谢谢了.
这里是编译时出现的错误
后面是程序源代码.
[yttx@localhost programe]$ gcc getlocal_infor.c -o getlocal_infor
getlocal_infor.c: In function `main':
getlocal_infor.c:17: warning: assignment makes pointer from integer without a cast
getlocal_infor.c:20: dereferencing pointer to incomplete type
getlocal_infor.c:22: dereferencing pointer to incomplete type
[yttx@localhost programe]$
#include <stdio.h>
#include <sys/utsname.h>
int main()
{
struct hostent *h;
struct utsname myname;
if(uname(&myname)<0)
return 1;
printf("sysname: %s\n",myname.sysname);
printf("nodename:%s\n",myname.nodename);
printf("release:%s\n",myname.release);
printf("version:%s\n",myname.version);
printf("machine information:%s\n",myname.machine);
/* 就是这一行,如果这样写h=gethostbyname(myname.nodename);,错误是一样的*/
h=gethostbyname((char *)myname.nodename);
char **addr;
addr=h->h_addr_list;
printf("IP Address is:\n");
printf("%s\n",inet_ntoa(*(struct in_addr *)*addr));
return 0;
} |
|