请帮忙看一下这段程序
char hostname[100];
char hostIP[100];
HOSTENT *pHostEnt;
gethostname(hostname,100);
pHostEnt = gethostbyname(hostname);
strcpy(hostIP,inet_ntoa(*(struct in_addr *)pHostEnt->h_addr_list[0]));
功能是取得本机的ip地址放在字符串hostip中
但执行到最后一行出错:
First-chance exception in ip.exe: 0xC0000005: Access Violation
特向各位大虾请教