netdb.h头文件倒底该怎么包含?
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char *argv[])
{
if (argc < 2)
{
fprintf(stderr, "Missing host name\n");
exit (1);
}
/* Address resolution */
hen = gethostbyname(argv[1]);
if (!hen)
{
perror("couldn't resolve host name");
}
}
cc -0 test test.c后,提示
gethostbyname引用错误,我查过,gethostbyname确是在netdb.h里。