//inet_ntoa.c //demonstration os inet_ntoa() #include<sys/socket.h> #include<netinet/in.h> #include<arpa/inet.h> #include<stdio.h> #include<sys/types.h> #include<stdlib.h> #include<string.h> int main(int argc,char *argv[]) { struct sockaddr_in addr; int z,sockfd; z=socket(AF_INET,SOCK_STREAM,0); if(z<0) { perror("socket error"); exit(0); } memset(&addr,0,sizeof addr); addr.sin_family=AF_INET; addr.sin_port=htons(8000); z=inet_aton("192.168.33.7",&addr.sin_addr); if(z<0) { printf("inet_aton error!!!/n"); exit(1); } printf("the remote IP is %s/n",inet_ntoa(addr.sin_addr)); }