Public domain
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
int main()
{
char *src = "83.170.42.20";
struct in_addr dst;
memset(&dst, 0, sizeof dst);
inet_pton(AF_INET, src, &dst);
printf("Presentation = %s\n", src);
printf("Network = %X\n", dst.s_addr);
return 0;
}
BY: Pejman Moghadam
TAG: c, inet-pton
DATE: 2014-01-21 02:04:17