C
81
hostname
Guest on 25th April 2022 10:17:37 PM
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
int main() {
WSADATA WSAData;
WSAStartup(MAKEWORD(2,0), &WSAData);
struct hostent *host;
int i;
host = gethostbyname("www.google.com");
if (host != NULL) {
printf("Nom officiel : %s\n",host
->h_name
);
for (i = 0; host->h_aliases[i] != NULL; i++)
printf("Alias : %s\n",host
->h_aliases
[i
]);
for (i = 0; host->h_addr_list[i] != NULL; i++)
inet_ntoa(*(struct in_addr *)host->h_addr_list[i]));
}
WSACleanup();
return 0;
}