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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -