Convert IP address in C -
i have:
192.168.1.1
how can convert it?
i have tried splitting ip address sscanf like:
sscanf(hostaddress,"%d.%d.%d.%d", &d1, &d2, &d3, &d4);
i have ip address [...] how can convert long?
you'e looking function inet_pton(3)
.
unsigned char buf[sizeof(struct in_addr)] rc = inet_pton(af_inet, "192.168.1.1", buf);
and rc
should 1 success. return code of 0 or -1 means error.
Comments
Post a Comment