我在 C 中执行以下操作以从主机名获取 IP 地址。它打印IP是?*?,所以它不起作用。我究竟做错了什么?
char * targetHostName = server_proxy_hostname;
char * targetPort = server_proxy_port;
struct hostent *info;
info = gethostbyname(targetHostName);
char ** ipAddresslist;
ipAddresslist =info -> h_addr_list;
char * ipAddress = ipAddresslist[0];
printf("IP is %s\n", ipAddress);