【发布时间】:2012-01-09 06:14:36
【问题描述】:
我正在尝试使用函数 gethostbyname,但是我的代码:
int handleTCP(char *hostname, char* portNo){
struct hostent *hp = gethostbyname(hostname);
...
}
不断返回:
21: warning: initialization makes pointer from integer without a cast
有人知道我的语法有什么问题吗?
谢谢
【问题讨论】:
-
如果 Evan 的回答不是问题所在:向我们展示更多代码,尤其是第 21 行是否是您向我们展示的代码之一。
-
您的代码顶部是否确定有
#include <sys/socket.h>? -
@OliCharlesworth:netdb.h 就是你所需要的。
标签: c sockets tcp gethostbyname