IP address to binary in C -


i have ip address so:

address = '192.168.1.11'; 

and need convert binary format

11000000 10101000 00000001 00001011 

i have ideas on how leftshift decimal number , using inet_addr, not sure how go doing it.

thanks, i'm still new c.

there socket function specific transforming text ip 32-bit "longip" address, might unecessary in context. simple form parse using sscanf():

char ip[] = "192.168.1.11"; int n1, n2, n3, n4; sscanf(ip, "%d.%d.%d.%d", &n1, &n2, &n3, &n4).  // result:  // n1 = 192 // n2 = 168 // n3 = 1 // n4 = 11 

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 -