September 27th, 2012, 11:13 AM
How to convert IP to hex using C++ ?
Hi guy .
I don`t known how to convert IP to hex .
In this link http://www.mustat.com/184.108.40.206 (Ip host codeguru.com) . I see hex IP : Hex IP 0x462a1779
I want to convert IP "220.127.116.11" to "0x462a1779"
Did you try IP "18.104.22.168" , IP hex : 0x7b1e800a
UINT32 ip_to_hex(UINT32 ip_add)
//code convert ip to hex
When i try "%x" , it`s wrong
printf("%x \n", 123);
printf("%x \n", 30);
printf("%x \n", 128);
printf("%x \n", 10);
And this is result
7b 1e 80 and a , not 0a
further i think we must separate each octect by a (dot) . , Then convert decimal to hexa
Can you help me ?
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!