C - Convert quad-dotted-decimal notation into binary data in network byte order and vice versa ============================================================================================== Public domain ******************************************************************************** ### -- 1 -- #include #include #include int main() { struct in_addr addr; char ip[]="192.168.29.57"; if (inet_aton(ip, &addr) == NULL) { perror("inet_aton"); exit(EXIT_FAILURE); } printf("%lu\n", addr.s_addr); exit(EXIT_SUCCESS); } ******************************************************************************** ### -- 2 -- #include #include #include int main() { struct in_addr addr; char *ip; addr.s_addr=958245056; if ((ip=inet_ntoa(addr)) == NULL) { perror("inet_ntoa"); exit(EXIT_FAILURE); } printf("%s\n", ip); exit(EXIT_SUCCESS); } ******************************************************************************** _BY: Pejman Moghadam_ _TAG: c, inet-aton, inet-ntoa_ _DATE: 2011-02-23 00:14:00_